Hash Table (Mid)

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/7

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:09 PM on 3/27/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

8 Terms

1
New cards
<p><strong>Two Sum</strong></p>

Two Sum

Hashmap value → index

  1. For each x, compute target - x

  2. If exists in map → return indices

  3. Else store x → i

    O(n)

2
New cards
<p><strong>Ransom Note</strong></p>

Ransom Note

Char frequency count:

  1. Count chars in magazine

  2. For each char in ransomNote, decrement

  3. If any count < 0 → false

    Can use array of size 26

3
New cards
<p><strong>Group Anagrams</strong></p>

Group Anagrams

Hash by normalized key:

  1. Sort string OR use 26-char frequency tuple

  2. Map key → list of strings

  3. Return all groups

4
New cards
<p><strong>Insert Delete GetRandom O(1)</strong> (LC380)</p>

Insert Delete GetRandom O(1) (LC380)

Use array + hashmap

  1. Map: value → index

  2. Insert → append to array, store index

  3. Remove → swap with last element, pop

  4. Update hashmap

  5. GetRandom → random index from array

    All ops O(1)

5
New cards
<p><strong>First Missing Positive (H)</strong></p>

First Missing Positive (H)

Index placement trick:

  1. While 1 <= x <= n and not in correct position → swap to x-1

  2. After pass, first index i where nums[i] != i+1 → answer i+1

  3. Else return n+1

    In-place, O(n)

6
New cards
<p><strong>LRU Cache</strong></p>

LRU Cache

Hashmap + Doubly Linked List:

  1. Map key → node

  2. DLL keeps order (most recent at front)

  3. Get → move node to front

  4. Put → insert/update at front

  5. If over capacity → remove tail

    All ops O(1)

7
New cards
<p><strong>All O(1) Data Structure</strong> (AllOne) (H)</p>

All O(1) Data Structure (AllOne) (H)

Hashmap + Doubly Linked List of counts:

  1. Map key → node (node stores count)

  2. DLL stores buckets of same count

  3. Inc/Dec → move key to next/prev count bucket

  4. Remove empty buckets

  5. Head = min, Tail = max

    All ops O(1)

8
New cards
<p><strong>Design and Implement LFU Cache (H)</strong></p>

Design and Implement LFU Cache (H)

Hashmap + frequency lists:

  1. Map key → (value, freq)

  2. Map freq → DLL of keys

  3. Track minFreq

  4. Get → increase freq, move key to next freq list

  5. Put → if full, evict from minFreq list (LRU within same freq)

  6. Insert new key with freq = 1

    All ops O(1)

Explore top notes

note
Research Designs
Updated 1281d ago
0.0(0)
note
Inherited Traits
Updated 1282d ago
0.0(0)
note
12-03: Rational Functions
Updated 566d ago
0.0(0)
note
History Study
Updated 1037d ago
0.0(0)
note
Lecture Exam 3 Review
Updated 515d ago
0.0(0)
note
Research Designs
Updated 1281d ago
0.0(0)
note
Inherited Traits
Updated 1282d ago
0.0(0)
note
12-03: Rational Functions
Updated 566d ago
0.0(0)
note
History Study
Updated 1037d ago
0.0(0)
note
Lecture Exam 3 Review
Updated 515d ago
0.0(0)

Explore top flashcards

flashcards
Phamacognosy (1-100 questions)
100
Updated 130d ago
0.0(0)
flashcards
AP Microeconomics Graphs (copy)
23
Updated 998d ago
0.0(0)
flashcards
unit 8 key terms
32
Updated 1158d ago
0.0(0)
flashcards
Spanish vocab quiz 5
20
Updated 864d ago
0.0(0)
flashcards
Phamacognosy (1-100 questions)
100
Updated 130d ago
0.0(0)
flashcards
AP Microeconomics Graphs (copy)
23
Updated 998d ago
0.0(0)
flashcards
unit 8 key terms
32
Updated 1158d ago
0.0(0)
flashcards
Spanish vocab quiz 5
20
Updated 864d ago
0.0(0)