#22 - Prefix Search
Problem Statement:
You are given a list of words. Your task is to implement a prefix search function that efficiently finds all words in the list that have a given prefix.
Example 1
Input
words = ["apple", "banana", "application", "apricot", "ball", "cat"]
prefix = "ap"
Output
["apple", "application", "apricot"]
Example 2
Input
words = ["python", "java", "javascript", "c++", "c#", "swift"]
prefix = "j"
Output
["java", "javascript"]
Last updated