Skip to content

Adding Word Suggest System #3786

@shivu2002a

Description

@shivu2002a

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions