Modified ex4 of assignment 4 use 1-indexing instead of 0-indexing