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):
return s[::-1]
本文介绍了一个简单的Python函数,该函数接收一个字符串作为输入并返回其反转后的字符串。例如,输入为hello时,输出为olleh。通过使用Python的切片功能,实现了简洁高效的字符串反转。
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):
return s[::-1]
4744

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