This commit is contained in:
parent
ec9e48aafa
commit
b23b0179f0
1 changed files with 17 additions and 0 deletions
17
medium/find_unique_binary_string.py
Normal file
17
medium/find_unique_binary_string.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# https://leetcode.com/problems/find-unique-binary-string
|
||||
|
||||
from typing import List
|
||||
|
||||
class Solution:
|
||||
def findDifferentBinaryString(self, nums: List[str]) -> str:
|
||||
length = len(nums)
|
||||
kv = {num: True for num in nums}
|
||||
result = ''
|
||||
fmt = '0' + str(length) + 'b'
|
||||
max = 2 ** length
|
||||
for i in range(max):
|
||||
result = format(i, fmt)
|
||||
if result not in kv:
|
||||
break
|
||||
return result
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue