Leetcode 55 跳跃游戏如何设计成长尾词?

2026-03-30 14:090阅读0评论SEO资源
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计143个文字,预计阅读时间需要1分钟。

Leetcode 55 跳跃游戏如何设计成长尾词?

题目描述:判断能否跳过障碍到达终点

方法一:bool canJump(vector nums){ int k=0; for (int i=0; i =nums.size()) return true; k=max(k, i + nums[i]); } return false;}

题目描述

方法一

bool canJump(vector<int>& nums)
{
int k = 0;
for (int i = 0; i < nums.size(); i++)
{
if (i > k) return false;
k = max(k, i + nums[i]); #k为当前能向前跳的最大距离
}
return true;
}

参考链接
​​​ leetcode-cn.com/problems/jump-game/solution/55-by-ikaruga/​​

Leetcode 55 跳跃游戏如何设计成长尾词?

​​leetcode-cn.com/problems/jump-game/solution/tiao-yue-you-xi-by-leetcode/​​


本文共计143个文字,预计阅读时间需要1分钟。

Leetcode 55 跳跃游戏如何设计成长尾词?

题目描述:判断能否跳过障碍到达终点

方法一:bool canJump(vector nums){ int k=0; for (int i=0; i =nums.size()) return true; k=max(k, i + nums[i]); } return false;}

题目描述

方法一

bool canJump(vector<int>& nums)
{
int k = 0;
for (int i = 0; i < nums.size(); i++)
{
if (i > k) return false;
k = max(k, i + nums[i]); #k为当前能向前跳的最大距离
}
return true;
}

参考链接
​​​ leetcode-cn.com/problems/jump-game/solution/55-by-ikaruga/​​

Leetcode 55 跳跃游戏如何设计成长尾词?

​​leetcode-cn.com/problems/jump-game/solution/tiao-yue-you-xi-by-leetcode/​​