1426. Counting Elements

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1426

class Solution:
    def countElements(self, arr: List[int]) -> int:
        cnt = Counter(arr)
        return sum(v for x, v in cnt.items() if cnt[x + 1])