mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
Update0055.跳跃游戏,添加C#
This commit is contained in:
@ -258,6 +258,23 @@ object Solution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
### C#
|
||||||
|
```csharp
|
||||||
|
public class Solution
|
||||||
|
{
|
||||||
|
public bool CanJump(int[] nums)
|
||||||
|
{
|
||||||
|
int cover = 0;
|
||||||
|
if (nums.Length == 1) return true;
|
||||||
|
for (int i = 0; i <= cover; i++)
|
||||||
|
{
|
||||||
|
cover = Math.Max(i + nums[i], cover);
|
||||||
|
if (cover >= nums.Length - 1) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
|
Reference in New Issue
Block a user