There was an error while loading. Please reload this page.
1 parent 81fd398 commit bf62affCopy full SHA for bf62aff
1 file changed
data_structures/arrays/reverse_array.py
@@ -1,5 +1,5 @@
1
"""
2
-In-place array reversal.
+In-place array reversal that also returns the list to the caller.
3
This algorithm reverses the elements of a list without using extra space.
4
5
@@ -34,6 +34,12 @@ def reverse_array(arr: list[Any]) -> list[Any]:
34
[1]
35
>>> reverse_array([])
36
[]
37
+ >>> reverse_array(list(range(5)))
38
+ [0, 1, 2, 3, 4]
39
+ >>> reverse_array(tuple(range(5)))
40
41
+ >>> reverse_array(range(5))
42
43
44
left = 0
45
right = len(arr) - 1
0 commit comments