v_yanushkovsky

#55 Jump Game

Aug 10th, 2026
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. bool canJump(vector<int>& nums) {
  2.     int farthest = 0;
  3.  
  4.     for (int i = 0; i < nums.size(); ++i){
  5.         if (i > farthest)
  6.             return false;
  7.  
  8.         farthest = max(farthest, i + nums[i]);
  9.     }
  10.  
  11.     return true;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment