Reverse String

 

344. Reverse String

Solution

  1. Reverse from both start and end.
    def reverseString(self, s):
     """
     :type s: List[str]
     :rtype: None Do not return anything, modify s in-place instead.
     """
     l = len(s)
     for i in range(l // 2):
         lc, rc = s[i], s[l-1-i]
         tmp = lc
         s[i] = rc
         s[l-1-i] = tmp