problem
solution
option 1 - dp
可能會time out
1 | class Solution { |
option 2 - Binary Search
1 | class Solution { |
analysis
- option 1 - dp
- time complexity
O(n^2)
- space complexity
O(n^2)
- time complexity
- option 2 - binary search
- time complexity
O(nlogn)
- space complexity
O(n)
- time complexity