problem
solution
option 1 - sorting
1 | class Solution { |
option 2 - hash table
1 | class Solution { |
analysis
- option 1
- time complexity
O(n)
- space complexity
O(1)
- time complexity
- option 2
- time complexity
O(n)
- space complexity
O(1)
- time complexity
1 | class Solution { |
1 | class Solution { |
O(n)
O(1)
O(n)
O(1)