Autocomplete / Suggestions

Problem Statement

Given a prefix, return all words from the trie that start with this prefix (autocomplete feature).

Example: Prefix = "app", Words = ["apple","app","application"] → ["apple","app","application"]

Approach: Trie DFS

Explanation: Traverse trie to prefix node, then DFS from that node to collect all words.

Time Complexity: O(P + K*L), P = prefix length, K = #words with prefix, L = avg word length

Space Complexity: O(N*L) for trie