Hashing

Concept shape

Practice pattern
key
bucket 0
bucket 1
bucket 2
bucket 3
Definition

Count how many times values or characters appear, usually with a map or fixed-size array.

Step 1 / 5
Concept shape
Current lesson

Frequency Counting Lab

Hashing Practice pattern

Frequency Counting

Welcome to the Frequency Counting concept lab. Count how many times values or characters appear, usually with a map or fixed-size array. The must know points are: Common for anagrams and duplicates. Fixed alphabets can use arrays. Maps handle arbitrary keys. The common operations are: increment count, decrement count, compare counts. The complexity shape is Usually O(n) time and O(k) space. Watch out for these pitfalls: Not removing zero-count keys when comparing maps. Using nested loops instead of counts. Related algorithms include Valid Anagram, Sliding Window.

Concept details

Count how many times values or characters appear, usually with a map or fixed-size array.

Must know

  • Common for anagrams and duplicates.
  • Fixed alphabets can use arrays.
  • Maps handle arbitrary keys.

Complexity

Usually O(n) time and O(k) space

Open deeper visual structure lesson
1.0x