Replies: 2 comments
-
#189. 189. Rotate Array |
Beta Was this translation helpful? Give feedback.
0 replies
-
Answered by Liner |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The space complexity of this algorithm is O(n) due to the slicing operations. Even though nums is supposed to be modified in place, each slicing operation effectively creates a new list that occupies space in memory.
Auxiliary Space:
Although the algorithm modifies the original list without creating additional data structures that grow in proportion to the input size (like dictionaries or additional lists), the temporary lists created by slicing still contribute to the auxiliary space complexity. Hence, this remains O(n).
Answered by Liner
Beta Was this translation helpful? Give feedback.
All reactions