hash_table.state
Input
Hash table
Current look-up
Match / window
Stored entry
What is Ransom Note
Can you cut the note out of a magazine? Each magazine letter may be used at most once. Count the magazine, then spend one count per note letter. A missing or exhausted letter means no.
aa, magazine aab. After counting a:2 b:1, the note spends two a’s and succeeds. Try note a magazine b to watch a miss.Interactive trace
Pseudocode & Complexity
| Operation | Time |
|---|---|
| Count magazine | O(m) |
| Spend note | O(n) |
| Space | O(Σ) |
Python implementation