Started with the naive recursive solution because my brain just went there first, and they immediately asked about stack overflow.
Start by clarifying the problem constraints (e.g., expected input size, whether recursion is acceptable) and then present multiple solutions: naive recursion, memoization, iterative DP, and matrix exponentiation. Discuss the time and space complexity of each and recommend the iterative approach for general use, while mentioning matrix exponentiation for very large n. Finally, address handling very large inputs by using arbitrary-precision arithmetic or modular arithmetic if needed.
Pro tip: For very large n, mention that Fibonacci numbers grow exponentially, so you might need to return the result modulo a large prime or use a library like Python's built-in big integers. Also, note that the iterative approach uses O(1) space and O(n) time, which is optimal for a single query.
Ask about constraints: what is the range of n? Should the function handle negative inputs? Is recursion allowed? Do we need exact values or modulo?
Describe naive recursion (exponential time), memoization (O(n) time and space), iterative DP (O(n) time, O(1) space), and matrix exponentiation (O(log n) time).
For each solution, state time and space complexity. Highlight that iterative is best for single queries, while matrix exponentiation is best for very large n or multiple queries.
Discuss that Fibonacci numbers grow exponentially, so for large n, exact values become huge. Suggest using arbitrary-precision arithmetic (e.g., Python's int) or modular arithmetic if only the remainder is needed.
Write clean code for the chosen approach, handle edge cases (n=0, n=1), and test with small and large inputs. Mention potential optimizations like fast doubling.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.