problem
solution
option 1 - set
1 | class Solution { |
option 2 - improve set
1 | class Solution { |
option 3 - sorting
1 | class Solution { |
option 4 - binary search
1 | class Solution { |
analysis
- option 1
- time complexity
O(nlogn)
- space complexity
O(n)
- time complexity
- option 2
- time complexity
O(n)
- space complexity
O(1)
- time complexity
- option 3 - sorting
- time complexity
O(nlogn)
- space complexity
O(1)
- time complexity
- option 4 - binary search
- time complexity
O(nlogn)
- space complexity
O(1)
- time complexity