public int Solution(int n) { if(n < 3) { return 1; }else { int[] arr = new int[n]; arr[0] = 1; arr[1] = 1; for(int i = 3;i <= n;i++) { arr[i] = arr[i-1] + arr[i-2]; } return arr[n]; } }
时间: 2024-11-05 23:19:35
public int Solution(int n) { if(n < 3) { return 1; }else { int[] arr = new int[n]; arr[0] = 1; arr[1] = 1; for(int i = 3;i <= n;i++) { arr[i] = arr[i-1] + arr[i-2]; } return arr[n]; } }