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