How would you implement an autocomplete method to return first n suggestions(input: search query, stored word/phrase suggestions, n) each suggestion has a word/phrase accompanied by a score Follow up. How would you extend this solution to optimize on memory/performance, if input is scaled up.
Sigiloso
naive solution: manually sort suggestions and return follow up: implemented trie, i hadn't implemented one from scratch before and as a result came up slow.