Skip to content

Commit 02b6dca

Browse files
committed
reviewed
1 parent 43b6c5e commit 02b6dca

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

data_structures/arrays/rotate_array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
def rotate_array(arr: list[int], k: int) -> list[int]:
1+
def rotate_array(arr: list[int], steps: int) -> list[int]:
22
"""
3-
Rotates the array to the right by k steps
3+
Rotates the array to the right by a given number of steps
44
55
Args:
66
arr (list[int]): The input array.
@@ -18,7 +18,7 @@ def rotate_array(arr: list[int], k: int) -> list[int]:
1818
[]
1919
"""
2020
n = len(arr)
21-
k = k % n if n else 0
21+
k = steps % n if n else 0
2222

2323
arr.reverse() # Reverse the entire array
2424
arr[:k] = reversed(arr[:k]) # Reverse the first k elements

0 commit comments

Comments
 (0)