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
f82d4e1036
commit
bca5e52671
@ -58,7 +58,8 @@ def rotate_array_n_space(nums: list[int], k: int) -> list[int]:
|
||||
>>> rotate_array_n_space([8, -7, 22, -6], 9)
|
||||
[-6, 8, -7, 22]
|
||||
"""
|
||||
|
||||
length = len(nums)
|
||||
k = k % length
|
||||
return nums[-k:] + nums[:k]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user