添加0509斐波那契数C#版本

This commit is contained in:
xiaoyu2018
2022-09-25 16:02:41 +08:00
parent f48f7b0aa7
commit 5ac7f64381

View File

@ -425,5 +425,25 @@ object Solution {
}
```
### C#
```c#
public class Solution {
public int ClimbStairs(int n) {
if(n<=2) return n;
int[] dp = new int[2] { 1, 2 };
for (int i = 3; i <= n; i++)
{
int temp = dp[0] + dp[1];
dp[0] = dp[1];
dp[1] = temp;
}
return dp[1];
}
}
```
-----------------------
<div align="center"><img src=https://code-thinking.cdn.bcebos.com/pics/01二维码一.jpg width=500> </img></div>