Search⌘ K
AI Features

DIY: Suggest Relevant Sentences

Explore how to implement a suggestion system that predicts and ranks relevant sentence completions from a continuous input stream. Learn to handle dynamic data by updating historical inputs and producing top-ranked suggestions efficiently.

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 ...