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.
To be honest I've never thought about how array initialization adds the computational complexity to the algorithm as a whole. And have never seen this idea in the books I've read (I'd be glad if you could recommend some literature that covers it at this level). Nevertheless my algorithm is defininely an algorithm that needs the array to be initialized, so your point is completely valid.
The last point is completely valid too. It's just we had already had a multiplication version here, so I wanted to show more concise addition-only version.
As for hashtable, could you elaborate on why you say hashtable has O(log(m)) insert/lookup time? I always thought it's amortized O(1). Otherwise I aggree that if the number of encountered buckets is much less than K then Hashtable variant will be preferable.
Cookie support is required to access HackerRank
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 →
Thanks for your valuable additions.
To be honest I've never thought about how array initialization adds the computational complexity to the algorithm as a whole. And have never seen this idea in the books I've read (I'd be glad if you could recommend some literature that covers it at this level). Nevertheless my algorithm is defininely an algorithm that needs the array to be initialized, so your point is completely valid.
The last point is completely valid too. It's just we had already had a multiplication version here, so I wanted to show more concise addition-only version.
As for hashtable, could you elaborate on why you say hashtable has O(log(m)) insert/lookup time? I always thought it's amortized O(1). Otherwise I aggree that if the number of encountered buckets is much less than K then Hashtable variant will be preferable.