mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-28 03:48:38 +00:00
Added rotate_array.py
This commit is contained in:
parent
bca5e52671
commit
90b278080c
@ -60,7 +60,7 @@ def rotate_array_n_space(nums: list[int], k: int) -> list[int]:
|
||||
"""
|
||||
length = len(nums)
|
||||
k = k % length
|
||||
return nums[-k:] + nums[:k]
|
||||
return nums[-k:] + nums[: length - k]
|
||||
|
||||
|
||||
# Time: O(n) Space: O(k)
|
||||
|
Loading…
x
Reference in New Issue
Block a user