Simple C++ solution


  • 3
    H
    class Solution {
    public:
        bool canJump(vector<int>& nums) {
            int target = nums.size()-1;
            
            for(int i = target-1; i >= 0; i--){
                if(nums[i]+i >= target) target = i;
            }
            
            return target == 0;
        }
    };

Log in to reply
 

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