1772. Sort Features by Popularity

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1772

class Solution:
    def sortFeatures(self, features: List[str], responses: List[str]) -> List[str]:
        cnt = Counter()
        for s in responses:
            for w in set(s.split()):
                cnt[w] += 1
        return sorted(features, key=lambda w: -cnt[w])