Dsa
Trie
Easy
Weighted Autocomplete
You are building an autocomplete engine. Each word in the dictionary has a popularity score. When a user types a prefix, you must return the word with that prefix that has the HIGHEST popularity score. If there is a tie, return the lexicographically smaller word. If no word matches, print 'NONE'.
Example:
Input:
3
hi 10
hello 20
high 15
1
h
Output:
hello
Key concepts
triesortingmax-value-path
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now