Implement Trie

Medium · Tries · Trie · Hash Table · String · Design

Problem

Build a prefix tree over lowercase words:

Tests replay a call sequence: the first entry names the class, each later entry is a method with its arguments, and calls returning nothing report None.

Examples

Input: insert("apple"), search("apple"), search("app"), startsWith("app"), insert("app"), search("app")
Output: True, False, True, then True

"app" is a prefix of "apple" but was not itself inserted — until it is.

Constraints

Approaches

Related problems

Start free on Cariara · Coding problems · System design studio

Starting Python
No results yet.

          
↑↓ move ↵ open esc close

Labs

Loading labs…

Run with your own input

Starting Python

Loading Python…