leetcode-easy-string-344 Reverse String

mycode

class Solution(object):
    def reverseString(self, s):
        """
        :type s: List[str]
        :rtype: None Do not return anything, modify s in-place instead.
        """
        s = s.reverse()

 

Reference: Faster

class Solution(object):
    def reverseString(self, s):
        """
        :type s: List[str]
        :rtype: None Do not return anything, modify s in-place instead.
        """
        temp = ""
        for i in range(len(s) / 2):
            temp = s[i]
            s[i] = s[len(s)-1-i]
            s[len(s)-1-i] = temp

 

Guess you like

Origin www.cnblogs.com/rosyYY/p/10993964.html