CS-OA cs-vo Faang

  1. Search Suggestion System
    For an array of n strings products and a word to search, search, designa system that, when each character of the searched word is typed,suggests at most three product names from the products array. Thesuggested products should share a common prefix with the searchedword. lf more than three products exist with a common prefix, reportthe three product names that appear first in lexicographical order.
    Return the suggested products, which will be a list of lists after eachcharacter of the searched word is typed.
    Note: A string xis considered lexicographically smaller than anotherstring yif xwill occur before yin the English dictionary.
    ExampleSuppose n = 5, products = ["carpet", "cart", "car", "camera", "crate"],and search = "camera".



Leave a Reply

Your email address will not be published. Required fields are marked *