1
class Solution:
2
def shortestCompletingWord(self, licensePlate: str, words: List[str]) -> str:
3
newPlate = "" # modify the licensePlate
4
for i in licensePlate:
5
if i.isalpha():
6
newPlate += i.lower()
7

8
c = Counter(newPlate)
9
l1 = [] # store (word,len,index)
10
for idx, word in enumerate(words):
11
if Counter(word) >= c:
12
l1.append((word, len(word), idx))
13
l1.sort(key=lambda x: (x[1], idx))
14
return l1[0][0]

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0