Leetcode 1620 Solution

This article provides solution to leetcode question 1620 (check-if-array-pairs-are-divisible-by-k)

https://leetcode.com/problems/check-if-array-pairs-are-divisible-by-k

Solution

class Solution:
    def canArrange(self, arr: List[int], k: int) -> bool:
        m = [0] * k

        for v in arr:
            m[v % k] += 1

        for i in range(1, k):
            if i * 2 == k:
                if m[i] % 2 == 1:
                    return False
            else:
                if m[i] != m[k - i]:
                    return False

        return True