Error
|
|
---|---|
@Ibrahim Nash | 5761 |
@blackshadows | 5715 |
@akhayrutdinov | 5111 |
@mb1973 | 4989 |
@Quandray | 4944 |
@saiujwal13083 | 4506 |
@sanjay05 | 3762 |
@marius_valentin_dragoi | 3516 |
@sushant_a | 3459 |
@verma_ji | 3341 |
@KshamaGupta | 3318 |
Complete Leaderboard | |
|
|
@aroranayan999 | 1115 |
@bt8816103042 | 739 |
@thealchemist627 | 456 |
@dalwainazism125 | 453 |
@akashkale117 | 453 |
@shivanandp12345678910 | 453 |
@codeantik | 448 |
@SherlockHolmes3 | 447 |
@SHOAIBVIJAPURE | 430 |
@shalinibhataniya1097 | 408 |
@ShamaKhan1 | 392 |
Complete Leaderboard |
Given a positive integer N. Calculate the Fibonacci series till the number N. If N is a part of the series, include N as well.
Example 1:
Input:
N = 1
Output:
0 1 1
Explanation:
Since 1 is part of the Fibonacci series,
the required series is upto 1.
Example 2:
Input:
N = 5
Output:
0 1 1 2 3 5
Explanation:
The required series is upto 5(since 5 is
a part of the series).
Note: The answer for N=6 and N=7
will be the same since the next term
(i.e. 8) is greater than the
respective Ns.
Your Task:
You don't need to read input or print anything.Your Task is to complete the function nFibonacci() that takes an integer N as input parameter and returns a list of integers containing all terms of the fibonacci series up until N.
Expected Time Complexity:O(N)
Expected Auxillary Space:O(1)
Constraints:
1<=N<=109
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes