6 lines concise and easy understand c++ solution


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

Log in to reply
 

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