You are viewing a single comment's thread. Return to all comments →
Wouldn't this actually be O(n+k)?
Not critizing as the Python solution I came up with (given below) is basically the same idea and would have the same bounds.
def divisibleSumPairs(n, k, ar): mod = [0 for i in range(k)] count = 0 for i, v in enumerate(ar): addend = (k - v % k) % k count += mod[addend] mod[v % k] += 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 →
Wouldn't this actually be O(n+k)?
Not critizing as the Python solution I came up with (given below) is basically the same idea and would have the same bounds.