55. Jump Game

PHOTO EMBED

Thu Feb 23 2023 08:13:00 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

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

https://leetcode.com/problems/jump-game/