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()

 

参考:更快

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

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2021-07-04
  • 2021-06-24
猜你喜欢
  • 2021-09-13
  • 2021-04-24
  • 2022-02-12
  • 2021-07-11
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案