public class Solution { //1 1 2 3 public int Fibonacci(int n) { if(n <= 2) return 1 ; int[] dp = new int[2] ;//滚动数组 int l_l = 0 ; int l = 1 ; dp[l_l] = 0 ; dp[l] = 1 ; for(int i = 2 ; i <= n ; i ++) { dp[(l + 1) % 2] = dp[l] + dp[l_l] ; l = (l + 1) % 2 ; l_l = (l_l + 1) % 2 ; } return dp[l] ; } }