FastPrepFibonacci Number with Constant Extra Space
Problems/Fibonacci Number with Constant Extra Space

Fibonacci Number with Constant Extra Space

ZipRecruiter logoZipRecruiter● EasyNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A ZipRecruiter new-grad phone-screen report describes a Fibonacci exercise and a follow-up that needs constant extra space without storing the sequence. The report leaves out the shape of the result, the indexing, limits, and a function signature. Our version uses the standard zero-based nth value with a signed 64-bit limit.

Return the n-th Fibonacci number, where F(0)=0, F(1)=1, and F(n)=F(n-1)+F(n-2).

Function

fibonacci(n: int) → long

Examples

Example 1

n = 2return = 1

F(2)=F(1)+F(0)=1.

Example 2

n = 10return = 55

The tenth Fibonacci number is 55.

Constraints

  • 0 <= n <= 91.

More ZipRecruiter Phone Screen questions

  • Neighboring Record IDsPHONE SCREEN · Seen May 2026
  • Restaurant Vote LeadersPHONE SCREEN · ONSITE INTERVIEW · Seen Feb 2026
  • Most Frequent Word across Grouped ArraysPHONE SCREEN · Seen Sep 2024
  • Starting Value with the Longest Collatz ChainPHONE SCREEN · Seen Apr 2022
  • Classify an Alien Dictionary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2022
  • Multiset Intersection of Three ListsPHONE SCREEN · Seen Feb 2022
  • Find the Smallest Magic IndexPHONE SCREEN · Seen Dec 2021
  • Website Pair with the Most Common VisitorsPHONE SCREEN · Seen Nov 2021
  • Center-Outward Number SpiralPHONE SCREEN · Seen Jun 2021
  • Missing Ranges within Inclusive BoundsPHONE SCREEN · Seen Feb 2021

Similar questions at other companies

  • Biased Coin: Probability of Exactly h HeadsAkuna Capital · PHONE SCREENAkuna Capital interview questions
  • Dice Sum That Is a Multiple of mSusquehanna International Group (SIG) · PHONE SCREENSusquehanna International Group (SIG) interview questions
  • Probability of Consecutive HeadsSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
  • Count Staircase WaysGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Climbing StairsGoogle · PHONE SCREENGoogle interview questions
  • Count Routes Through a City GridIMC Trading · PHONE SCREENIMC Trading interview questions
  • Ways to Climb n StairsAdobe · PHONE SCREENAdobe interview questions
  • Heads in Fair Coin FlipsJane Street · PHONE SCREENJane Street interview questions
  • Climbing StairsBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Climbing StairsExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions

ZipRecruiter interview experiences

  • ZipRecruiter SWE OA, Level Not Reported: 23 Experiences
  • ZipRecruiter SWE Intern OA Scores: 4 Experiences
  • ZipRecruiter SWE New Grad OA: 9 Experiences
All ZipRecruiter interview questionsSee ZipRecruiter hiring insights
Saved
class Solution {
    public long fibonacci(int n) {
      // Write your code here.
    }
}
Checking account…