Find Unique Binary String

Medium Topics Company Tags

The array nums contains n distinct binary strings, each exactly n characters long. Return any binary string of length n that is not present in nums.

Only the characters 0 and 1 are allowed. If several strings satisfy the requirement, any of them is accepted.

Example 1:

Input: nums = ["000","101","110"]

Output: "001"

Explanation: "001" has length 3, contains only binary digits, and is absent from nums. Other absent strings of length 3 are also accepted.

Example 2:

Input: nums = ["1"]

Output: "0"

Explanation: The only input string is "1", so "0" is the missing binary string of length 1.

Example 3:

Input: nums = ["00","11"]

Output: "01"

Explanation: "01" is absent from the input and has length 2. Returning "10" would also be correct.

Constraints:

  • 1 <= nums.length <= 16
  • Each string has exactly nums.length characters.
  • Each character is either 0 or 1.
  • All strings in nums are distinct.


Topics

Company Tags

Please upgrade to NeetCode Pro to view company tags.