Generate Fibonacci Sequence — LeetCode 2648 Python Solution

EasyJavaScript
Problem
#2648
Reading time
2 min

The problem

Write a generator function that returns a generator object which yields the fibonacci sequence. The fibonacci sequence is defined by the relation Xn = Xn-1 + Xn-2.

Example

Input
callCount = 5
Output
[0,1,1,2,3]
Explanation
const gen = fibGenerator();

Complexity

MeasureComplexity
TimeO(n)
SpaceO(1) to O(n) auxiliary

Related problems

Frequently asked questions

How hard is LeetCode 2648. Generate Fibonacci Sequence?
LeetCode 2648. Generate Fibonacci Sequence is rated Easy on LeetCode.
What topics does LeetCode 2648. Generate Fibonacci Sequence cover?
LeetCode 2648. Generate Fibonacci Sequence is tagged JavaScript on LeetCode.

Stuck on problems like this in a live interview?

Stealth Interview is a desktop app for macOS and Windows. It reads the problem off your screen and returns a working solution with a step-by-step explanation and its time and space complexity — invisible to screen sharing.

Get Stealth Interview