Update0055.跳跃游戏,添加C#
This commit is contained in:
parent
6eadd3eafc
commit
e209d35143
|
|
@ -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">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue