(num: int)
| 188 | cache: dict[int, int] = {0: 0, 1: 1, 2: 1} # Prefilled cache |
| 189 | |
| 190 | def rec_fn_memoized(num: int) -> int: |
| 191 | if num in cache: |
| 192 | return cache[num] |
| 193 | |
| 194 | value = rec_fn_memoized(num - 1) + rec_fn_memoized(num - 2) |
| 195 | cache[num] = value |
| 196 | return value |
| 197 | |
| 198 | return [rec_fn_memoized(i) for i in range(n + 1)] |
| 199 |