Hash Map
Everything on SkillVeris tagged Hash Map — collected across the glossary, study notes, blog, and cheat sheets.
11 resources across 2 libraries
Study Notes(1)
Interview Questions(10)
What is a Hash Table?
A hash table is a data structure that maps keys to values using a hash function to compute an index into an array of buckets, giving average O(1) insertion, lo…
Solve the Two Sum Problem
The optimal solution to Two Sum scans the array once while keeping a hash map of value to index, checking on every element whether its complement (target minus…
How Would You Design an LRU Cache?
An LRU (Least Recently Used) cache is designed by combining a hash map for O(1) key lookup with a doubly linked list that keeps items ordered by recency, so th…
How Do You Find the Number of Subarrays That Sum to K?
You solve subarray-sum-equals-k in O(n) time by tracking a running prefix sum and a hash map of how many times each prefix sum value has occurred so far, since…
Minimum Window Substring: How Do You Solve It?
Minimum window substring is solved with a variable-size sliding window and two hash maps: expand the right pointer until the window contains every required cha…
Longest Substring Without Repeating Characters
The longest substring without repeating characters is found with a sliding window and a hash map that stores the last seen index of each character: expand the…
How Do You Clone a Linked List with a Random Pointer?
You clone a linked list where each node has both a next pointer and a random pointer (which may point anywhere in the list or to null) by first mapping every o…
How Do You Find a Subarray With a Given Sum?
For arrays of non-negative integers, a sliding window expands and shrinks two pointers over the array to find a contiguous subarray summing to a target in O(n)…
How Would You Design a Concurrent Hash Map?
A concurrent hash map achieves thread-safe reads and writes at scale by splitting the table into independently lockable segments (or per-bucket locks) instead…
The hashCode() and equals() Contract
The hashCode()/equals() contract requires that whenever two objects are equal according to equals(), they must return the identical hashCode(), so that hash-ba…