时间复杂度(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))】
推荐阅读
- LeetCode|LeetCode 53. Maximum Subarray 时间复杂度(O(n))
- LeetCode 55. Jump Game 时间复杂度(O(n))
- LeetCode|LeetCode 42. Trapping Rain Water 时间复杂度(O(n))
- leetcode|算法入门之字符串(Python)【初级算法——字符串】【蓝桥杯练习】【力扣练习】
- Python|【蓝桥杯真题】Python备战28天
- #|LeetCode344. 反转字符串
- 算法|LeetCode Golang Hot53-最大子数组和
- leetcode|leetcode 344.反转字符串(reverse string)C语言
- LeetCode 668. 乘法表中第k小的数