首页 > 其他 > 详细

leetcode-easy-string-344 Reverse String

时间:2019-06-09 17:12:24      阅读:104      评论:0      收藏:0      [点我收藏+]

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

 

leetcode-easy-string-344 Reverse String

原文:https://www.cnblogs.com/rosyYY/p/10993964.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!