Skip to content

Commit 7c5b92e

Browse files
authored
Merge pull request neetcode-gh#1222 from sxsmg/1980-Find-Unique-Binary-String
Create 1980-Find-Unique-Binary-String.py
2 parents 78d8e2a + c528235 commit 7c5b92e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution:
2+
def findDifferentBinaryString(self, nums: List[str]) -> str:
3+
4+
strSet = { s for s in nums }
5+
6+
def backtrack(i, cur):
7+
if i == len(nums):
8+
res = "".join(cur)
9+
return None if res in strSet else res
10+
11+
res = backtrack(i+1, cur)
12+
if res: return res
13+
14+
cur[i] = "1"
15+
res = backtrack(i+1, cur)
16+
if res: return res
17+
18+
return backtrack(0, ["0" for s in nums])
19+

0 commit comments

Comments
 (0)