Asymptotic Analysis (Hard) Flashcards
1
Q
Four Number Sum
A
Time:
O(n^2) average
O(n^3) worst
Space: O(n^2)
2
Q
SubArray Sort
A
Time:
O(n)
Space:
O(1)
3
Q
Same BSTs
A
Time:
O(n^2)
Space:
O(n^2)
(but O(d) is technically possible)
4
Q
Largest Range
A
Time:
O(n)
Space:
O(n)
5
Q
Min Rewards
A
Time:
O(n)
Space:
O(n)
6
Q
Zigzag Traverse
A
Time:
O(n)
Space:
O(n)