642. Missing Binary Word
You are given a list words of different binary words (made of the characters 0 and 1), all of the same length L. The list is shorter than the number of binary words of that length, so at least one word of length L is missing from it.
Return any binary word of length L that is not in the list. Many answers are usually correct, so a checker verifies that the returned word has length L, uses only 0 and 1, and is not in words.
Example 1
- Input:
- words = ["01","10"]
- Output:
- "00"
- Explanation:
The words
00and11are missing. Any of them is accepted; the reference answer is the smallest one,00.
Example 2
- Input:
- words = ["0"]
- Output:
- "1"
- Explanation:
Only
1is missing.
Example 3
- Input:
- words = ["000","001","010","011","100"]
- Output:
- "101"
- Explanation:
The missing words are
101,110and111; the smallest,101, is the reference answer.
Constraints
- 1 ≤
L≤ 16 and 1 ≤words.length< 2^L, withwords.length≤ 100 - All words have length
L, contain only0and1, and are pairwise different.
How this problem is judged
- Answers
- Any valid answer is accepted. A checker tests yours against the problem's rules.
Expected complexity
- Time
- O(m * L)
- Space
- O(m * L)