filmov
tv
Fibonacci series up to Nth term #gfg #leetcode #java
Показать описание
You are given an integer n, return the fibonacci series till the nth(0-based indexing) term. Since the terms can become very large return the terms modulo 109+7.
Example 1:
Input:
n = 5
Output:
0 1 1 2 3 5
Explanation:
0 1 1 2 3 5 is the Fibonacci series up to the 5th term.
Example 2:
Input:
n = 10
Output:
0 1 1 2 3 5 8 13 21 34 55
Explanation:
0 1 1 2 3 5 8 13 21 34 55 is the Fibonacci series up to the 10th term.
Your Task:
You don't need to read input or print anything. Your task is to complete the function Series() which takes an Integer n as input and returns a Fibonacci series up to the nth term.
Expected Time Complexity: O(n)
Expected Space Complexity: O(n)
#gfg #leetcode #programming #coding #java
#questions #array #String #list #linkedlist #arraylist #map
#hashmap #linkedhashmap #treemap #iterator #loops #algorithm #dsa #datastructures #set #graph #dynamicprogramming #dp #memorization #tabulation #greedy #arraylist #bits #bitmanupulation #divide #and #conquer #reurssion #backtracking #linux #potd #problemoftheday #school #basic #easy #medium #hard #testing #sprint #dsasheet
Example 1:
Input:
n = 5
Output:
0 1 1 2 3 5
Explanation:
0 1 1 2 3 5 is the Fibonacci series up to the 5th term.
Example 2:
Input:
n = 10
Output:
0 1 1 2 3 5 8 13 21 34 55
Explanation:
0 1 1 2 3 5 8 13 21 34 55 is the Fibonacci series up to the 10th term.
Your Task:
You don't need to read input or print anything. Your task is to complete the function Series() which takes an Integer n as input and returns a Fibonacci series up to the nth term.
Expected Time Complexity: O(n)
Expected Space Complexity: O(n)
#gfg #leetcode #programming #coding #java
#questions #array #String #list #linkedlist #arraylist #map
#hashmap #linkedhashmap #treemap #iterator #loops #algorithm #dsa #datastructures #set #graph #dynamicprogramming #dp #memorization #tabulation #greedy #arraylist #bits #bitmanupulation #divide #and #conquer #reurssion #backtracking #linux #potd #problemoftheday #school #basic #easy #medium #hard #testing #sprint #dsasheet