本文整理汇总了Python中collections.Counter.isalpha方法的典型用法代码示例。如果您正苦于以下问题:Python Counter.isalpha方法的具体用法?Python Counter.isalpha怎么用?Python Counter.isalpha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collections.Counter
的用法示例。
在下文中一共展示了Counter.isalpha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shortestCompletingWord
# 需要导入模块: from collections import Counter [as 别名]
# 或者: from collections.Counter import isalpha [as 别名]
def shortestCompletingWord(licensePlate, words):
"""
:type licensePlate: str
:type words: List[str]
:rtype: str
"""
d = {}
licensePlate = licensePlate.lower()
for c in licensePlate:
if c.isalpha():
d[c] = d.get(c, 0) + 1
res1 = ''
res2 = ''
length1 = length2 = 20
for word in words:
n = len(word)
all_in, flag = f(n, word, d)
if all_in and n < length1:
res1 = word
length1 = n
if flag and n < length2:
res2 = word
length2 = n
if res1:
return res1
return res2