Implement a function to calculate the nth number in the Fibonacci sequence using dynamic programming.
HardProblem Statement
Implement a function to calculate the nth number in the Fibonacci sequence using dynamic programming.
Sample Input
n = 10
Sample Output
55
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
// Calculate nth Fibonacci number using dynamic programming
function fibonacciDP(n) {
// Initialize an array with base cases
// Iterate up to n, storing results in the array
// Return the nth result
}
console.log(fibonacciDP(10));
Input
n = 10
Expected Output
55