dsa · easy

Implement Trie (Prefix Tree)

GreyOrangeTreeDesignHash MapFoundation

Implement a prefix tree.

Methods

Fill in the Trie class. The starter already walks ops / args and calls your methods — leave the driver at the bottom as-is. Constructors contribute null; booleans print as true / false.

**Example**

`` Trie() → null insert("apple") → null search("apple") → true search("app") → false startsWith("app") → true insert("app") → null search("app") → true ``

Constraints

word length <= 20, calls <= 300

Examples

Example 1

Input:
["Trie","insert","search","search","startsWith","insert","search"]
[[],["apple"],["apple"],["app"],["app"],["app"],["app"]]

Expected:
[null,null,true,false,true,null,true]

Open in the Dojo editor