0055.cpp (240B)
1 class Solution { 2 public: 3 bool canJump(vector<int> &nums) { 4 int n = nums.size(), limit = 0; 5 for (int i = 0; i <= limit && i < n; i++) 6 limit = max(limit, i + nums[i]); 7 return limit >= n - 1; 8 } 9 };