leetcode 1170 python

mac2026-08-17  2

题目要求: https://leetcode-cn.com/problems/compare-strings-by-frequency-of-the-smallest-character/submissions/

class Solution: def numSmallerByFrequency(self, queries: List[str], words: List[str]) -> List[int]: ret, queries_count, words_count = [], [], [] words_count = [word.count(min(word)) for word in words] for query in queries: c = query.count(min(query)) # 在 words_count 里数一下有多少是比 c 大的 ret.append(len([x for x in words_count if c < x])) return ret
最新回复(0)