攀爬字符串

问题

    great
/    \
gr    eat
/ \    /  \
g   r  e   at
/ \
a   t

    rgeat
/    \
rg    eat
/ \    /  \
r   g  e   at
/ \
a   t

    rgtae
/    \
rg    tae
/ \    /  \
r   g  ta  e
/ \
t   a

思路

1. great
2. great
3. great
4. great

实现

class Solution:
# @param {string} s1 A string
# @param {string} s2 Another string
# @return {boolean} whether s2 is a scrambled string of s1
def isScramble(self, s1, s2):
l = len(s1)
if l == 1:
return s1 == s2
if l == 2:
if s1 == s2:
return True
if s1[0] == s2[1] and s1[1] == s2[0]:
return True
return False
for i in range(1,l):
left1 = s1[0:i]
left2 = s2[0:i]
right1 = s1[i:]
right2 = s2[i:]
left2r = s2[:l-i]
right2r = s2[l-i:]
if (self.isScramble(left1,right2r) and self.isScramble(right1,left2r)) or (self.isScramble(left1,left2) and self.isScramble(right1,right2)):
return True

return False 

攀爬字符串-LintCode

2017-10-16 18:52:48

简单几步教你制作植物攀爬到建筑上

2016-06-02 13:01:25

[Unity3D]Unity3D游戏开发之MatchTarget实现角色攀爬效果

2014-07-29 18:33:07

Unity3D游戏开发之MatchTarget实现角色攀爬效果

2016-11-23 16:51:32

利用Mecanim动画系统中的MatchTarget来实现角色攀爬效果

2017-05-25 15:46:12

Unity 自动寻路Navmesh之跳跃,攀爬,斜坡

2015-07-17 10:29:47

html5休闲游戏《动物攀爬》截图

2018-05-07 15:06:14

lintcode(430)攀爬字符串

2017-06-09 10:58:02

编程题——攀爬字符串

2017-08-28 17:23:35

【HTCVR】VRTK插件案例分析之001~010

2017-08-18 10:04:59