LeetCode 45. Jump Game II 时间复杂度(O(n))

时间复杂度(O(n))

class Solution { public: int jump(vector& nums) { if(nums.size()<=1)return 0; vector jumpCount(nums.size(),INT_MAX); jumpCount[0]=0; int curr_index=0; for(int i=1; ijumpCount[i-1]) jumpCount[j]=jumpCount[i-1]+1; curr_index=j; } } return jumpCount.back(); } };

【LeetCode 45. Jump Game II 时间复杂度(O(n))】

    推荐阅读