Leetcode 1620 Solution
This article provides solution to leetcode question 1620 (check-if-array-pairs-are-divisible-by-k)
Access this page by simply typing in "lcs 1620" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
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