You are viewing a single comment's thread. Return to all comments →
Python
def divisibleSumPairs(n, k, ar): ar_mod = [i%k for i in ar] count_mod = {} for i in ar_mod: if i not in count_mod: count_mod[i] = 0 count_mod[i] += 1 count = 0 for i in ar_mod: count_mod[i] -= 1 if i != 0: sub = k-i else: sub = 0 if sub in count_mod: count += count_mod[sub] return count
Seems like cookies are disabled on this browser, please enable them to open this website
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
Python