Skip to main content

Command Palette

Search for a command to run...

When life throws you lemons, use a hash-map

by Suhail Moidin

Published
1 min read
When life throws you lemons, use a hash-map

1_w1waqqUssb5gVpbzxAY2CQ.png

Before we get started, let's have a quick overview of what a hash-map actually is. A hash-map as the name suggest is a value that is mapped to another value. The mapped and the mapping value in this case need not be of the same type. The mapping value is called the KEY. If the programmer has access to the key, he can in turn access its corresponding value.

Hash-map is a very popular data structure that comes in pretty handy when it comes to solving Leetcode or Competitive coding problems. In fact, there are memes circulating around in the coding space in regards to how effective and life saving a hash map is.

yo-dawg-i-heard-you-like-hashmaps-so-i-put-a-hashmap-in-your-hashmap-so-you-can-hash-while-you-map.jpeg

Reflecting on the Title

So why hash-maps. Why is it so popular? What is all the buzz around it? Hmmm... It would be quite challenging to explain it to someone whose never coded but let's just pretend that it gets a good chunk of job done. The only drawback I can think of is the potential of collision when 2 distinct keys generate the same hashCode value. But that's something I look forward to covering in my upcoming articles.

1_eOcS6MFMkWxxSjnlb6SsBA.jpeg