products
array.result
to store the lists of suggestions.searchWord
, do the following:
a. Add the character to the current prefix
.
b. Perform a binary search on products
to find the first product that matches the prefix
.
c. From the index found, add up to three products to the current list of suggestions.
d. Append the current list of suggestions to result
.result
.