Search⌘ K

DIY: Suggest Relevant Sentences

Explore how to design a suggestion system that predicts how strings might end by providing the top three relevant sentence completions. Learn to implement real-time input processing, track historical data, and rank suggestions efficiently to improve search experience.

Problem statement

Design a system that will guess how a specific string will end. This system will make suggestions by tracking the history of strings that it has seen before. The input() function should take a continuous stream of input, which will end when "#" is found. Each call to the ...