forked from Frank96Zhang/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
659197e
commit b54766b
Showing
1 changed file
with
9 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### 087.Scramble-String | ||
|
||
基本的思想就是:在S1上找到一个切割点,左边长度为i, 右边长为len - i。 有2种情况表明它们是IsScramble | ||
|
||
(1). S1的左边和S2的左边是IsScramble, S1的右边和S2的右边是IsScramble | ||
|
||
(2). S1的左边和S2的右边是IsScramble, S1的右边和S2的左边是IsScramble (实际上是交换了S1的左右子树) | ||
|
||
我们可以在递归中加适当的剪枝:在进入递归前,先把2个字符串排序,再比较,如果不相同,则直接退出掉。 |