PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

Implement nth Fibonacci number evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

  • easy
  • Intuit
  • Coding & Algorithms
  • Data Scientist

Implement nth Fibonacci number

Company: Intuit

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Onsite

# Implement nth Fibonacci number ## Problem Write a function that returns the **n-th Fibonacci number**. The Fibonacci sequence is defined as: - \(F(0)=0\) - \(F(1)=1\) - \(F(n)=F(n-1)+F(n-2)\) for \(n \ge 2\) ### Requirements - Input: integer `n` (assume `n >= 0`). - Output: integer `F(n)`. - Discuss time/space complexity and how you would handle large `n`. ### Follow-ups (if asked) - Avoid recursion stack overflow. - Optimize for time (e.g., better than \(O(n)\)) or for very large values. ### Constraints & Assumptions - Preserve the scope, facts, inputs, and requested outputs from the prompt above. - If the prompt leaves a detail unspecified, state a reasonable assumption before relying on it. - Keep the answer interview-ready: concise enough to present, but concrete enough to implement or evaluate. ### Clarifying Questions to Ask - Clarify input sizes, value ranges, mutability, return format, and tie-breaking. - State the target time and space complexity before coding. - Call out edge cases such as empty inputs, duplicates, invalid values, overflow, and boundary sizes. ### What a Strong Answer Covers - A clear algorithm with the right data structures and enough pseudocode or code-level detail to implement it. - A correctness argument that explains why the algorithm covers all required cases. - Time and space complexity, plus at least one alternative approach when relevant. - Focused tests for normal cases, edge cases, and failure modes. ### Follow-up Questions - How would the approach change if the input were streaming or too large for memory? - What invariants would you assert in production code? - Which tests would catch off-by-one, duplicate, or tie-breaking bugs?

Quick Answer: Implement nth Fibonacci number evaluates algorithm design, data structures, correctness, complexity, edge cases, and implementation details in a realistic interview setting. A strong answer states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.

Return F(n) with F(0)=0, F(1)=1 using fast doubling.

Constraints

  • n >= 0

Examples

Input: (0,)

Expected Output: 0

Explanation: Base case.

Input: (1,)

Expected Output: 1

Explanation: Base case.

Input: (10,)

Expected Output: 55

Explanation: F(10).

Input: (50,)

Expected Output: 12586269025

Explanation: Large enough to show iterative recursion avoids exponential work.

Hints

  1. Fast doubling computes F(2k) and F(2k+1) from F(k), F(k+1).
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Increment a Digit-Array Integer by One - Intuit (medium)
  • Add One to Digit Array - Intuit (easy)
  • Validate bracket sequence - Intuit (easy)
  • Find Business Degrees of Separation - Intuit (hard)
  • Produce valid student lineup from parent array - Intuit (medium)