Now, head to LeetCode and implement the memoized solution yourself. Try writing it from scratch without looking at the code provided. Think through the recurrence relation, identify the base cases, then add memoization. The implementation follows directly from the recurrence. Time complexity: .
Space complexity: for the memoization table storing each subproblem result.