Update.0045跳跃游戏2,添加C#版本二

This commit is contained in:
eeee0717
2023-12-30 10:16:43 +08:00
parent e209d35143
commit a66e5e39ba

View File

@ -464,6 +464,27 @@ impl Solution {
}
}
```
### C#
```csharp
// 版本二
public class Solution
{
public int Jump(int[] nums)
{
int cur = 0, next = 0, step = 0;
for (int i = 0; i < nums.Length - 1; i++)
{
next = Math.Max(next, i + nums[i]);
if (i == cur)
{
cur = next;
step++;
}
}
return step;
}
}
```
<p align="center">
<a href="https://programmercarl.com/other/kstar.html" target="_blank">