My Blog List

[Leetcode Solution] Jump Game II

Analysis 

  • Let f[x] denote the minimum steps needed to jump to x.
    • f[y]=min(f[x]+1) if x + A[x]>=y
  • O(n) algorithm can be found.
    • if the f[y]=f[x]+1 (x<y and x+A[x]>=y), then any position k ( x<k<y ) won't give f[y] a smaller value

Note

Code


No comments:

Post a Comment

Enter you comment