You are viewing a single comment's thread. Return to all comments →
Time: o(n) Space: o(n)
def divisibleSumPairs(n, k, arr): remainder_count = [0] * k count = 0 for num in arr: remainder = num % k complement = (k - remainder) % k count += remainder_count[complement] remainder_count[remainder] += 1 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 →
Time: o(n) Space: o(n)