[leetcode]344. Reverse String

344. Reverse String

Write a function that takes a string as input and returns the string reversed.

Example:
Given s = “hello”, return “olleh”.

这题本来就easy,用python更easy,具体代码如下所示

class Solution(object):
    def reverseString(self, s):
        """
        :type s: str
        :rtype: str
        """
        return s[::-1]

你可能感兴趣的:(数据结构与算法分析,python,leetcode)