Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
Subscribe to see which companies asked this question
不能更简单。。。。。
class Solution(object):
def reverseString(self, s):
return s[::-1]

本文介绍了一个简单的Python函数,该函数接收一个字符串作为输入并返回其反转后的字符串。例如,输入为'hello'时,输出为'olleh'。文章提供了一个简洁的实现方式,通过Python内置的切片操作符[::-1]来完成字符串的反转。

被折叠的 条评论
为什么被折叠?



