MCPcopy Create free account
hub / github.com/careercup/ctci / reverseStringRecursive

Function reverseStringRecursive

python/Chapter 1/Question1_2/ChapQ1.2.py:5–9  ·  view source on GitHub ↗
(str1)

Source from the content-addressed store, hash-verified

3#using recursion here to avoid recopying the string, as described in the discussion of "string buffer".
4
5def reverseStringRecursive(str1):
6 if str1 != "":
7 return str1[-1:] + reverseStringRecursive(str1[:-1])
8 else:
9 return ""
10
11#testing
12

Callers 1

ChapQ1.2.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected