Longest-Match Tokenization with UNK and Optional UNK-Run Compression
Asked at Anthropic · Coding Questions · Difficulty: Medium · Last asked Jun 26, 2026
Implement `tokenize(text, vocab)` that scans `text` from left to right and performs **longest-match tokenization** (a.k.a. maximal munch), returning a list of token ids.
Loading the problem…