problem
solution
optino 1 - dp
1 | class Solution { |
- can reduce space complexity
O(1)
s
option 2 - monotoic stack
1 | class Solution { |
analysis
- option 1
- time complexity
O(n)
- space complexity
O(n)
- time complexity
- option 2
- time complexity
O(n)
- space complexity
O(n)
- time complexity