We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I did O(n) in js using Maps.
I iterate over numbers a and then calculate mod and complementary to the mod needed for the sum equal k.
then i save complementary to hashmap and the value in the hashmap means how many numbers could make the pair. Since hashmap get and set are O(1) i assume i have O(n).
Divisible Sum Pairs
You are viewing a single comment's thread. Return to all comments →
I did O(n) in js using Maps. I iterate over numbers a and then calculate mod and complementary to the mod needed for the sum equal k. then i save complementary to hashmap and the value in the hashmap means how many numbers could make the pair. Since hashmap get and set are O(1) i assume i have O(n).