clueless coding // TODO: be smarter

LeetCode Jump Game: CPP Solution



TL;DR Code Solution


bool canJump(vector<int>& nums) {

    int maxi = 0;
    int i = 0;
    for (; i < nums.size() && i <= maxi; i++) {
        maxi = max(maxi, i + nums[i]);
    }
    return i == nums.size();

}