Solved JumpGame but in O(N^2) time