775. Global and Local Inversions ¶
Approach 1: Local inversions $\subseteq$ global inversions¶
- Time: $O(n)$
- Space: $O(1)$
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
1 2 3 4 5 6 7 8 9 10 |
|
Approach 2: Ideal permutation¶
- Time: $O(n)$
- Space: $O(1)$
1 2 3 4 5 6 7 8 9 |
|
1 2 3 4 5 6 7 8 |
|
1 2 3 4 5 6 |
|