Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 57b29ea

Browse files
author
Amogh Singhal
authored
Create reverse_in_place.py
1 parent 9cd30ee commit 57b29ea

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎reverse_in_place.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def reverse_in_place(arr):
2+
i = 0
3+
j = len(arr) - 1
4+
5+
while i != j and i<j:
6+
arr[i], arr[j] = arr[j], arr[i]
7+
i += 1
8+
j -= 1
9+
10+
return arr
11+
12+
result = reverse_in_place([4, 12, 14, 16, 18])
13+
print(result)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /