파비의 매일매일 공부기록

2023.11.17 Today's Challenge 본문

Problem Solving/LeetCode

2023.11.17 Today's Challenge

fabichoi 2023. 11. 17. 23:45

https://leetcode.com/problems/find-unique-binary-string/

 

Find Unique Binary String - LeetCode

Can you solve this real interview question? Find Unique Binary String - Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. If there are multiple answers, you

leetcode.com

조합을 만들어서 푸는 문제

class Solution:
    def findDifferentBinaryString(self, nums: List[str]) -> str:
        ints = set()
        for n in nums:
            ints.add(int(n, 2))
        l = len(nums)
        for n in range(l+1):
            if n not in ints:
                ans = bin(n)[2:]
                return "0" * (l - len(ans)) + ans
        
        return ""
반응형

'Problem Solving > LeetCode' 카테고리의 다른 글

2023.11.19 Today's Challenge  (0) 2023.11.19
2023.11.18 Today's Challenge  (0) 2023.11.18
2023.11.16 Today's Challenge  (0) 2023.11.16
2023.11.15 Today's Challenge  (0) 2023.11.15
2023.11.14 Today's Challenge  (0) 2023.11.14
Comments