写出一个程序,接受一个字符串,然后输出该字符串反转后的字符串。(字符串长度不超过1000)
数据范围:
要求:空间复杂度 ,时间复杂度
def solve(self , str: str) -> str: # write code here res = '' for i in str: res = i + res return res
class Solution: def solve(self , str: str) -> str: return str[::-1]
class Solution: def solve(self , str: str) -> str: # write code here test_list = [] for i in str: test_list.append(i) test_list.reverse() r = "".join(test_list) return r