(n, dic = { 1: 0, 2: 1 })
| 1 | // time O(n) |
| 2 | // space O(n) |
| 3 | function getNthFib(n, dic = { 1: 0, 2: 1 }) { |
| 4 | if (n in dic) return dic[n]; |
| 5 | dic[n] = getNthFib(n - 1, dic) + getNthFib(n - 2, dic); |
| 6 | return dic[n]; |
| 7 | } |
| 8 | |
| 9 | // time O(n) |
| 10 | // space O(1) |
nothing calls this directly
no outgoing calls
no test coverage detected