Hacker News new | ask | show | jobs
by moregrist 66 days ago
In a trivial sense, arrays are hash tables with a hash function of the identity f(x)=x.

It’s just not particularly common (or helpful) to view them that way.

1 comments

In LeetCode, it's a very common optimization. If your key values are dense, you use an array. If your key values are sparse, you use a dict.