leetpycode/medium/find_unique_binary_string.py

17 lines
460 B
Python

# 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