If I need to implement string reverse by myself in Python 2.7 other than using system library, wondering if any more efficient solutions? I tried my code runs slow for a very long string (e.g. a few thousand characters). Thanks.
For string reverse I mean, for example, given s = "hello", return "olleh".
def reverseString(self, s):
"""
:type s: str
:rtype: str
"""
if not s:
return ''
temp = []
result=''
for i in range(len(s)-1,-1,-1):
result += s[i]
return result
regards, Lin