1497. Check If Array Pairs Are Divisible by k

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

On This Page

LeetCode problem 1497

class Solution:
    def canArrange(self, arr: List[int], k: int) -> bool:
        cnt = Counter(x % k for x in arr)
        return cnt[0] % 2 == 0 and all(cnt[i] == cnt[k - i] for i in range(1, k))