zoukankan      html  css  js  c++  java
  • leetcode——796.旋转字符串

    class Solution:
        def rotateString(self, A: str, B: str) -> bool:
            if A=='' and B=='':
                return True
            elif A=='' or B=='':
                return False
            if len(A)!=len(B):
                return False
            a=list(A)
            b=list(B)
            if sorted(a)!=sorted(b):
                return False
            k=len(A)-1
            while k>0:
                c=a[0]
                a.remove(c)
                a.append(c)
                if a==b:
                    return True
                else:
                    k-=1
            return False
    执行用时 :32 ms, 在所有 Python3 提交中击败了100.00%的用户
    内存消耗 :13.8 MB, 在所有 Python3 提交中击败了5.26%的用户
     
    真棒!!
                                                                                      ——2019.10.9
    我的前方是万里征途,星辰大海!!
  • 相关阅读:
    CentOS7.4安装Docker
    责任链模式
    策略模式
    状态模式
    解释器模式
    备忘录模式
    中介者模式
    观察者模式
    迭代器模式
    private、default、protected和public的作用域
  • 原文地址:https://www.cnblogs.com/taoyuxin/p/11644567.html
Copyright © 2011-2022 走看看