# Leetcode 55. Jump Game ###### tags: `Leetcode(C++)` 題目 : https://leetcode.com/problems/jump-game/ 。 想法 : 更新能夠前往的最遠距離。 時間複雜度 : O(n)。 程式碼 : ``` class Solution { public: bool canJump(vector<int>& nums) { int l=nums.size(),now=nums[0]; for(int i=1 ; i<l ; i++){ if(i<=now){ now=max(now,i+nums[i]); } } if(now >= l-1) return true; return false; } }; ```