jump-game

作者: DaiMorph | 来源:发表于2019-07-18 23:34 被阅读0次
class Solution {
public:
    bool canJump(int A[], int n) {
        int reach=A[0];
        for(int i=0;i<=reach&&reach<n;i++)
            reach=max(reach,i+A[i]);
        return reach>=n-1;
    }
};

相关文章

网友评论

      本文标题:jump-game

      本文链接:https://www.haomeiwen.com/subject/cqkdlctx.html