Optimal Substructure: F(n) = F(n-1) + F(n-2), for n > 1
Solution 1: Dynamic Programming
Complexity Analysis
Time complexity : O(n). The recursive function is run once for each of the n nodes, and the body of the recursive function is O(1). Therefore, this gives a total of O(n).
AI Engineer. Innovative and results-driven. Adept at deploying cutting-edge models with high-performance apps. He transforms challenges into practical solutions