Grokking Meta Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Comparative Efficiency of Hashmap and Array access

Nicholas Tinsley

Sep 1, 2024

Is it actually cheaper to allocate a hash map and access its elements rather than just going through both sparse arrays at the same time? In either case, you have to iterate through each array and you have to do an equality check against 0; I don't understand how using the additional space complexity and the (constant but existent) overhead of a hash map optimizes the operation.

0

0

Comments
Comments
N
Nicholas Tinsleya year ago

Never mind, I read the solution page more closely and understand now.

On this page