thiagowfx's avatar

¬ just serendipity 🍀 (not just serendipity)

LeetCode #3595: Once Twice

• 25 words • 1 min

LeetCode #3595: Once Twice:

Counter:

python
from collections import Counter

class Solution:
    def onceTwice(self, nums: List[int]) -> List[int]:
        return [num for (num, _) in Counter(nums).most_common()[::-1][:2]]