plate, a string of digits, English letters in either case and spaces, and an array of words words.
A word *covers* the plate if it contains every letter of the plate, counting repeats: digits and spaces are ignored, letter case does not matter, and a letter that appears several times on the plate must appear at least that many times in the word. For example, the plate "kK 77a" is covered by "kayak" and "knack" but not by "kale".
Return the shortest word in words that covers the plate. If several words tie, return the one that comes first in the array. At least one covering word is guaranteed to exist.plate='7KA 2k9', words=['kayak', 'kick', 'karaoke', 'snack'] → 'kayak'
The plate holds k, a and another k. "kick" lacks an a and "snack" has only one k, while "kayak" and "karaoke" both fit; "kayak" is shorter.
plate='B 404', words=['crab', 'blue', 'bird', 'rob'] → 'rob'
Only the letter b is needed. Every word has one, and the shortest is "rob".
plate='Ox 12', words=['axon', 'oxen', 'box', 'fox'] → 'box'
All four words fit; "box" and "fox" tie at length 3, and "box" wins because it comes first.
plate.length ≤ 20plate consists of digits, English letters and spaceswords.length ≤ 1000words[i].length ≤ 15words[i] consists of lowercase English lettersplate='7KA 2k9', words=['kayak', 'kick', 'karaoke', 'snack']
'kayak'
Run checks the first 3 tests in your browser. Submit checks all 66 tests on the server, hidden ones included.