class Solution(object):
def isScramble(self, s1, s2):
"""
:type s1: str
:type s2: str
:rtype: bool
"""
# NULL
n=len(s1)
if n==0:
return 1
if n==1:
return s1==s2
for i in range(n):
# core-->length==i
return (self.isScramble(s1[:i],s2[:i]) and self.isScramble(s1[i:],s2[i:])) or (self.isScramble(s1[:i], s2[-i:]) and self.isScramble(s1[-i:], s2[:i]))

solu=Solution()
# 赋值输出一条龙

print(solu.isScramble(s1 = "abcde", s2 = "caebd"))
print(solu.isScramble(s1 = "great", s2 = "rgeat"))
posted on 2019-08-14 11:23  黑暗尽头的超音速炬火  阅读(218)  评论(0编辑  收藏  举报