-
Notifications
You must be signed in to change notification settings - Fork 20.8k
Description
What would you like to Propose?
I found out that the Word Suggest System problem is not implemented. I'd like to contribute.
Word Suggest Problem Statement:
Given an array of strings products and a string searchWord
Design a system that suggests productNames from products after each character of _searchWord _ is typed.
Suggested products should have a common prefix with searchWord.
Return a list of lists of the suggested products after each character of searchWord is typed.
Issue details
Example:
products = {"man", "mango", "manage", "map", "you", "match", "manuscript", "monk"}
searchword = "man"
When m is typed
man, mango, manage, map, match, manuscript, and monk should be suggested
When a is typed
man, mango, manage, map, match, and manuscript should be suggested
When n is typed
man, mango, manage, and manuscript should be suggested
Finally, the 2D list of strings is returned
{
{man, mango, manage, map, match, manuscript, monk },
{man, mango, manage, map, match, manuscript },
{man, mango, manage, manuscript }
}
This can be solved by making use of Trie data structure.
Thank you.
Additional Information
No response