PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's understanding of algorithmic problem-solving, recurrence relations, numeric computation, and performance analysis, including discussion of time and space complexity and handling of large inputs or integer overflow.

  • medium
  • Plymouth Rock Assurance Corporation
  • Coding & Algorithms
  • Data Scientist

Compute Fibonacci Numbers

Company: Plymouth Rock Assurance Corporation

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Write a function that returns the `n`th Fibonacci number. Definitions and requirements: - Use zero-based indexing: `fib(0) = 0`, `fib(1) = 1`. - For `n >= 2`, `fib(n) = fib(n - 1) + fib(n - 2)`. - The input `n` is a non-negative integer. - Discuss the time and space complexity of your approach. - If relevant, explain how your implementation handles large `n` values or integer overflow.

Quick Answer: This question evaluates a candidate's understanding of algorithmic problem-solving, recurrence relations, numeric computation, and performance analysis, including discussion of time and space complexity and handling of large inputs or integer overflow.

Return the nth Fibonacci number using zero-based indexing.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: (0,)

Expected Output: 0

Explanation: fib(0) is 0.

Input: (1,)

Expected Output: 1

Explanation: fib(1) is 1.

Input: (10,)

Expected Output: 55

Explanation: fib(10) is 55.

Input: (30,)

Expected Output: 832040

Explanation: The iterative method handles larger n efficiently.

Hints

  1. Clarify edge cases before coding.
  2. Keep outputs deterministic when several valid answers exist.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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.