4 ms·
Agreed. This is a terrible source. For example, the rotate array is much better handles with a deque; you get amortized constant time rotations.
by ball_of_lint 10y ago
Agreed. This is a terrible source.
For example, the rotate array is much better handles with a deque; you get amortized constant time rotations.
- Sherxon 10y agoRight, Deque is also another option, which has the same amortized time complexity and but extra O(n) space is required for Queue. In the given solution, O(n) time complexity and O(1) space is used