Topic links: https://leetcode-cn.com/problems/jump-game-ii/
Subject to the effect:
slightly.
analysis:
Greedy + DP.
code show as below:
1 class Solution { 2 public: 3 int jump(vector<int>& nums) { 4 int jump = 0; 5 int cur = 0; 6 int next = 0; 7 8 for(int i = 0; i < nums.size(); ++i) { 9 if(cur < i) { 10 ++jump; 11 cur = next; 12 } 13 is Next = max (Next, the nums + i [i]); // will be able to jump to jump by i hops, hops because after jump can jump where i is greater than or equal, it is possible to calculate the first jump + 1 times where can jump far jump 14 } 15 return jump; 16 } . 17 };