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
我的前方是万里征途,星辰大海!!
原文地址:https://www.cnblogs.com/taoyuxin/p/11644567.html