Reverse String
Write a function that takes a string as input and returns the string reversed.
Example: Given s = "hello", return "olleh".
class Solution(object):
def reverseString(self, s):
"""
:type s: str
:rtype: str
"""
return s[::-1]
With out using [::-1]
class Solution(object):
def reverseString(self, s):
"""
:type s: str
:rtype: str
"""
res = [s[i] for i in reversed(range(len(s)))]
return ''.join(res)