目录标题
- 2023-8-11 09:49:25
45. 跳跃游戏 II
2023-8-11 09:49:25
自己没做出来,废物Orz
class Solution {public int jump(int[] nums) {int length = nums.length;int end = 0;int maxPosition = 0;int steps = 0;for (int i = 0; i < length - 1; i++) {maxPosition = Math.max(maxPosition, i + nums[i]);if (i == end) {end = maxPosition;steps++;}}return steps;}
}
贪婪算法思想: