problem
solution
option 1 - sorting
1 | // you can use includes, for example: |
option 2 - hash table
1 |
|
option 3 - swap
放到正確的位置
1 | // you can use includes, for example: |
analysis
- option 1
- time complexity
O(nlogn)
- space complexity
O(1)
- time complexity
- option 2
- time complexity
O(n)
- space complexity
O(n)
- time complexity
- option 3
- time complexity
O(n)
- space complexity
O(1)
- time complexity