Skip to content

Commit bf026b1

Browse files
committed
784
1 parent 04386fd commit bf026b1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

DFS/traditionalDFS/784.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## Is Graph Bipartite?
2+
3+
#### Description
4+
5+
[link](https://leetcode.com/problems/letter-case-permutation/)
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 letterCasePermutation(self, S: str) -> List[str]:
22+
res = []
23+
self.dfs("", S, res)
24+
return res
25+
26+
def dfs(self, pre, s, res):
27+
if s == '':
28+
res.append(pre)
29+
return
30+
if s[0].isdigit():
31+
self.dfs(pre + s[0], s[1:], res)
32+
else:
33+
self.dfs(pre + s[0].lower(), s[1:], res)
34+
self.dfs(pre + s[0].upper(), s[1:], res)
35+
```

0 commit comments

Comments
 (0)