problem
solution
option 0 - Insert sort
1 | class Solution { |
option 1 - sorting
1 | class Solution { |
1 | class Solution { |
option 3 - improve option 1
參考別人的
1 | class Solution { |
analysis
- option 1
- time complexity
O(n*n)
- space complexity
O(1)
- time complexity
- option 2
- time complexity
O(nlogn)
- space complexity
O(n)
- time complexity
- option 3
- time complexity
O(n)
- space complexity
O(1)
- time complexity