Start by clarifying the requirements: input size, expected output, and constraints. Then present multiple solutions (recursive, iterative, matrix exponentiation) with trade-offs, and implement the most efficient one. Discuss time/space complexity and potential optimizations like memoization or fast doubling.
Pro tip: Demonstrate awareness of integer overflow and use arbitrary-precision arithmetic if needed; also mention that Fibonacci can be computed in O(log n) using matrix exponentiation or fast doubling, which shows depth.
Ask about input range, expected output type, and constraints (e.g., n up to 10^6 or 10^18). Confirm whether recursion is acceptable or if iterative is preferred.
Mention simple recursion (exponential time) and iterative (linear time) solutions, highlighting their time and space complexities.
Introduce memoization (top-down DP) and bottom-up DP to reduce time to O(n). For large n, suggest matrix exponentiation or fast doubling for O(log n) time.
Write clean, efficient code for the selected approach, handling edge cases (n=0, n=1) and potential integer overflow.
Walk through time/space complexity, test with small and large inputs, and discuss trade-offs between approaches.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.