Given distinct binary strings of length , construct any binary string of length that does not appear in the list.
You are given an array of distinct binary strings, where each string has length . Your task is to return any binary string of length that is not present in the array.
A binary string contains only the characters 0 and 1. Because the input list contains unique strings of length , it is guaranteed that at least one valid answer exists.
This is a constructive problem: you do not need to find the lexicographically smallest answer, only any missing binary string is acceptable.
Input Format
Input
- An integer implied by the size of the array.
- An array of distinct binary strings, each of length .
Assumptions
- All strings contain only
0and1. - All strings in the array are unique.
Output Format
Output
- Return any binary string of length that does not occur in the given array.
Constraints
- for typical interview reasoning.
- The array contains exactly distinct strings.
- Each string has length exactly .
- Each character is either
0or1.
Note: The core guarantee is that a missing string always exists.
Example 1
Input
nums = ["01","10"]
Output
"11"
Explanation
There are four binary strings of length 2: 00, 01, 10, and 11. Since 11 is not in the list, it is a valid answer.
Example 2
Input
nums = ["111","011","001"]
Output
"010"
Explanation
Any binary string of length 3 that is not one of the three inputs is acceptable. Here, 010 is missing.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.