16ms c++ short solution


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

Log in to reply
 

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