We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eed3619 commit efb49e8Copy full SHA for efb49e8
DFS/traditionalDFS/756.md
@@ -0,0 +1,32 @@
1
+## Pyramid Transition Matrix
2
+
3
+#### Description
4
5
+[link](https://leetcode.com/problems/pyramid-transition-matrix/)
6
7
+---
8
9
+#### Solution
10
11
+- See Code
12
13
14
15
+#### Code
16
17
+> 最坏情况:O(n^2)
18
19
+```python
20
+class Solution:
21
+ def pyramidTransition(self, bottom: str, allowed: List[str]) -> bool:
22
+ pool=defaultdict(list)
23
+ for x in allowed: pool[x[:2]].append(x[2])
24
25
+ def dfs(bottom):
26
+ if len(bottom)==1: return True
27
+ for b in product(*(pool[x+y] for x,y in zip(bottom[:-1],bottom[1:]))):
28
+ if dfs(b): return True
29
+ return False
30
31
+ return dfs(bottom)
32
+```
0 commit comments