DeepOffer

Implement a BPE tokenizer from scratch: train merge rules, then encode and decode without external libraries.

ML CodingReported interview question
Reported in a public interview report — OpenAI (MLE coding round); take-home at Anthropic

Count adjacent symbol pairs, repeatedly merge the most frequent pair, and store the ordered merge table. Encoding reapplies merges by rank; decoding concatenates token bytes, so normalization and unknown-byte handling must be explicit.

Test empty input, one-element input, duplicates, boundary indices, invalid states, and the largest allowed size; state time and space complexity.

Common follow-up questions

Practice this question with an AI interviewer

Get asked follow-ups live, then receive a scored report — like a real MLE interview loop.

Start AI mock interview