12ms C++ Solution


  • 0
    W
    class Solution {
    public:
        bool canJump(vector<int>& nums) {
            int n = nums.size();
            int bound = nums.size()-1;
            for(int i=n-2;i>=0;--i)
                if(nums[i]+i>=bound) bound = i;
            if(bound == 0) return true;
            return false;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.