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 595c7f0

Browse files
author
Amogh Singhal
authored
Create reverse_str_recursive.py
1 parent fcbcfbe commit 595c7f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

‎reverse_str_recursive.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Given a string, get it reversed using recursion
2+
3+
def recursive_reverse(input_str):
4+
if len(input_str) == 0:
5+
return ''
6+
else:
7+
return recursive_reverse(input_str[1:]) + input_str[0]
8+
9+
result = recursive_reverse("aabbcc")
10+
print(result) # ccbbaa

0 commit comments

Comments
(0)

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