diff --git a/python/1268-Search-Suggestions-System.py b/python/1268-Search-Suggestions-System.py new file mode 100644 index 000000000..8ed201184 --- /dev/null +++ b/python/1268-Search-Suggestions-System.py @@ -0,0 +1,10 @@ +class Solution: + def suggestedProducts(self, products: List[str], searchWord: str) -> List[List[str]]: + products.sort() + res = [] + + for i in range(1, len(searchWord) + 1): + products = [p for p in products if p.startswith(searchWord[:i])] + res.append(products[:3]) + return res + \ No newline at end of file