MCPcopy
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / revstring

Function revstring

Stack.py:38–46  ·  view source on GitHub ↗
(mystr)

Source from the content-addressed store, hash-verified

36
37# 利用栈将字串的字符反转
38def revstring(mystr):
39 # your code here
40 s = Stack()
41 outputStr = ''
42 for c in mystr:
43 s.push(c)
44 while not s.isEmpty():
45 outputStr += s.pop()
46 return outputStr
47
48# print(revstring('apple'))
49# print(revstring('x'))

Callers

nothing calls this directly

Calls 4

pushMethod · 0.95
isEmptyMethod · 0.95
popMethod · 0.95
StackClass · 0.85

Tested by

no test coverage detected