Snap·Software Engineer·Technical Phone Screen
- Design a search autocomplete system where, as a user types one character at a time, you return the top 3 historical sentences matching the current prefix, ranked by frequency and then alphabetically. Typing '#' finalizes the input and increments that sentence's frequency count. How do you keep the per-node top-3 list efficient?
“I went straight to a Trie and explained how each node could cache its top 3 sentences so you don't have to re-scan everything on each keystroke.”