From f02eec32295b0208ff4b4abd070b67f0ef359f04 Mon Sep 17 00:00:00 2001 From: Vaidehi Date: Wed, 26 Nov 2025 14:56:53 +0530 Subject: [PATCH] Created 1268-Search-Suggestions-System.py --- python/1268-Search-Suggestions-System.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 python/1268-Search-Suggestions-System.py 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