classSolution:defshortestCompletingWord(self, licensePlate:str, words: List[str])->str:
s =[w for w in licensePlate.lower()iford(w)>=97andord(w)<=122]
words.sort(key=lambda x:len(x))#按单词长度进行排序for w in words:
w_copy=list(w)for i in s:#判断单词是否包含牌照所有字母if i in w_copy:
w_copy.remove(i)else:#不满足条件breakelse:return w #返回满足条件的单词
leetcode-5.22[*748. 最短完整词、653. 两数之和 IV - 输入 BST、821. 字符的最短距离](python实现)
题目1题解1class Solution: def shortestCompletingWord(self, licensePlate: str, words: List[str]) -> str: s = [w for w in licensePlate.lower() if ord(w)>=97 and ord(w)<=122] words.sort(key=lambda x:len(x)) #按单词长度进行排序 for