Hashing
Uses a hash map or set to store and look up values quickly.
Original Array
10
20
10
30
20
10
Hash Map (Frequency Count)
Map is empty
Initialize an empty hash map.
Where It's Used
- Checking if an element has appeared before.
- Counting frequencies of elements.
- Storing values for fast lookup.
- Tracking relationships between numbers or characters.
Problems Using This Pattern
Two Sum
Array + HashMap
Longest Substring Without Repeating Characters
Sliding Window
Subarray Sum Equals K
Prefix Sum + HashMap
Group Anagrams
Hashing + Sorting