Skip to content

Files

Latest commit

21f262e · May 16, 2019

History

History
21 lines (16 loc) · 644 Bytes

implement-trie-prefix-tree.md

File metadata and controls

21 lines (16 loc) · 644 Bytes

Implement a trie with insert, search, and startsWith methods.

Example:

Trie trie = new Trie();

trie.insert("apple");
trie.search("apple");   // returns true
trie.search("app");     // returns false
trie.startsWith("app"); // returns true
trie.insert("app");   
trie.search("app");     // returns true

Note:

  • You may assume that all inputs are consist of lowercase letters a-z.
  • All inputs are guaranteed to be non-empty strings.