LeetCode 1268 Search Suggestions System - Problem Statement

The problem

Given an array of products and a search word, return suggested products after each character typed.

After typing each character, suggest up to 3 products that share the current prefix, sorted lexicographically.

With products = ["mobile","mouse","moneypot","monitor","mousepad"] and searchWord = "mouse":

  • After "m": ["mobile","moneypot","monitor"] (first 3 alphabetically starting with "m")
  • After "mo": ["mobile","moneypot","monitor"]
  • After "mou": ["mouse","mousepad"]
  • After "mous": ["mouse","mousepad"]
  • After "mouse": ["mouse","mousepad"]

Constraints: 11 \le products 1000\le 1000. 11 \le searchWord length 1000\le 1000.