JS - Educative-HashMaps-01
Overview
Hash maps store data in the form of key-value pairs.
Unlike an array, when we want to find an element within array, we need to search the entire array, resulting in O(N) time.
On the contrary, hash maps allow us to have flexible keys. Each key is unique and is mapped against a value.
Therefore, we can look up its value in O(1) time.
Pattern that require HashMaps
- there is a need to access to data fast during the execution of the algorithm
- there is a need to store relationship between 2 sets of data in order to compute the required result
3 Primary Function
- Put(key, value) - inserts a key and value pair into the hash map.
- Get(key) - returns the value to which the key is mapped.
- Remove(key) - removes the key and its mapped value.