← Questions

Implement a trie (prefix tree)

0
AnthropicCodingLast asked Aug 2025

Implement a prefix tree over strings: insert a word, check whether a whole word is present, and check whether any stored word starts with a given prefix. Design the classes so that new operations can be added later without rewriting the structure, and explain the time and space cost of each operation.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding