mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
添加0509斐波那契数C#版本
This commit is contained in:
@ -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>
|
||||
|
Reference in New Issue
Block a user