leetcode - 344 - 反转字符串

class Solution:
    def reverseString(self, s):
        """
        :type s: str
        :rtype: str
        """
        L = len(s)
        out = ""
        for i in range(L):
            j = L - 1 - i
            out += s[j]
        return out


 # 使用切片更简单   s[: : -1]        

猜你喜欢

转载自blog.csdn.net/hustwayne/article/details/83584640
今日推荐