problem
solution
option 1 - recursive
1 | class Solution { |
option 1.1 memo pattern
1 | class Solution { |
option 2 - dp
1 | class Solution { |
option 3 - reduce dp
1 | class Solution { |
analysis
option 1
- time complexity
O(2^n)
- space complexity
O(1)
- time complexity
option 2
- time complexity
O(n)
- space complexity
O(n)
- time complexity
option 3
- time complexity
O(n)
- space complexity
O(1)
- time complexity