03 - Fibonacci Numbers - Dynamic Programming Top Down Memoization

@Rishi Srivastava Using Dynamic Programming Top Down approach, we solve using memoization technique. Memoization stores the result of expensive function calls (in arrays or maps) and returns the stored results whenever the same inputs occur again. Top Down memoization pseudocode: function memoizedFib(n, memo={}){ if (n === 0 || n === 1){ return n; } if (memo[n] == 0) { memo[n] = memoizedFib(n - 1, memo) memoizedFib(n - 2, memo); } return memo[n]; } Time complexity: O(n) Space complexity: O(n) Github: Leetcode:
Back to Top