LeetCode55. 跳跃游戏

LeetCode55.跳跃游戏

思路

可以看我的上篇博客跳跃游戏II

代码

cpp 复制代码
class Solution {
public:
    bool canJump(vector<int>& nums) {
        for(int i = 0, j = 0; i < nums.size(); i++){
            if(j < i) return false;
            j = max(j, i + nums[i]);
        }

        return true;
    }
};
相关推荐
让我们一起加油好吗9 小时前
【算法刷题】LeetCode 力扣 Hot 100 刷题记录
数据结构·c++·算法·leetcode·面试·笔试
Rain的Java大神之路9 小时前
LeetCode 42「接雨水」:面试官百出不厌的题,一文讲透从暴力到双指针 O(1)
java·后端·leetcode
Navigator_Z2 天前
LeetCode //C - 1320. Minimum Distance to Type a Word Using Two Fingers
c语言·算法·leetcode
wy_hhxx3 天前
[Leetcode] 滑动窗口
算法·leetcode·滑动窗口
伟大的车尔尼3 天前
贪心题目:最多可以参加的会议数目
贪心
AIgorithmGEEK3 天前
算法·哈希表|从“逐个比”到“按 key 算位置”
数据结构·c++·算法·leetcode·hash
Navigator_Z3 天前
LeetCode //C - 1319. Number of Operations to Make Network Connected
c语言·算法·leetcode
伟大的车尔尼4 天前
贪心题目:最小区间
贪心
Navigator_Z4 天前
LeetCode //C - 1318. Minimum Flips to Make a OR b Equal to c
c语言·算法·leetcode
驭渊的小故事4 天前
LeetCode 33:搜索旋转排序数组——从二分查找到旋转数组的区间判定
算法·leetcode·职场和发展