From b23b0179f04ae9e376700767b82ee9361ce51502 Mon Sep 17 00:00:00 2001 From: bumpsoo Date: Thu, 20 Feb 2025 11:46:07 +0000 Subject: [PATCH] https://leetcode.com/problems/find-unique-binary-string --- medium/find_unique_binary_string.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 medium/find_unique_binary_string.py diff --git a/medium/find_unique_binary_string.py b/medium/find_unique_binary_string.py new file mode 100644 index 0000000..5009444 --- /dev/null +++ b/medium/find_unique_binary_string.py @@ -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 +