Suggested Products

Problem Overview

  • After each character typed in the search string, return product names whose prefixes match the current search prefix.
  • Input: an array of unique product strings and a search string; Output: for each prefix, up to three lexicographically smallest matching products.
  • Real-world context: e-commerce autocomplete and suggested products in a search bar.
  • This coding interview problem is a common interview question from Square_point interviews.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: