天天看點

LeetCode刷題——344. 反轉字元串

題目

LeetCode刷題——344. 反轉字元串

思路

代碼

class Solution(object):
    def reverseString(self, s):
        """
        :type s: List[str]
        :rtype: None Do not return anything, modify s in-place instead.
        """
        i,j = 0,len(s)-1
        while i < j:
            s[i],s[j] = s[j],s[i] # python中互換數組中兩個元素便捷寫法!!
            i += 1
            j -= 1
        return