class Solution { public: int Fibonacci(int n) { int ans[40]; ans[1] = ans[2] = 1; for (int i = 3; i <= n; i++) { ans[i] = ans[i - 1] + ans[i - 2]; } return ans[n]; } };