请编写一个函数,其功能是将输入的字符串反转过来。
示例:
输入:s = "hello" 返回:"olleh"
class Solution:
def reverseString(self, s):
"""
:type s: str
:rtype: str
"""
list1 = []
for i in s:
list1.append(i)
list1.reverse()
str1 = ''
for j in list1:
str1 += j
print(str1)
s1 = Solution()
s1.reverseString("hello")
不会数据结构和算法的我,撸LeetCode分分钟想吐血....