Solution 1: accepted 237ms
Super slow! too much operations!
Time: O(n^2)
Space: O(n)
|
|
Solution 2: accepted 17ms
Though hashSet is more efficient, we can do better.
Time: O(n)
Space: O(n)
|
|
Solution 3: accepted 1ms
Time: O(n)
Space: O(1)
|
|
Super slow! too much operations!
Time: O(n^2)
Space: O(n)
|
|
Though hashSet is more efficient, we can do better.
Time: O(n)
Space: O(n)
|
|
Time: O(n)
Space: O(1)
|
|