forked from wisdompeak/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
bda9ff6
commit 3995e21
Showing
1 changed file
with
5 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,5 @@ | ||
### 291.Word-Pattern-II | ||
|
||
建立两个映射,Map1从pattern的字符指向str的字符串,Map2建议相反的映射。DFS的每个回合,尝试将pattern的一个字符与str的一个前缀配对起来。校验如果这个配对已经存在,那么就递归处理pattern和str的剩余部分。如果这个配对不存在,就创建这个配对,分别更新Map1和Map2,然后同样递归处理. | ||
|
||
注意这题需要回溯,即每次返回前需要清理Map1和Map2最新添加的元素。 |