Run time error for some test cases

can t clear all the test cases due to run time. Not sure if dp will be applied or not

  1. increase the size of array to 1000 as mention in the question
  2. print -1 for those cases when there is no possible path