Simple c++ solution


  • 0
    I
    bool canJump(vector<int>& nums) {
        int maxIdx = 0;
        for (int i = 0; i < nums.size() && i <= maxIdx; i++) maxIdx = max(maxIdx, i + nums[i]);
        return maxIdx >= nums.size() - 1;
    }

Log in to reply
 

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