May 14, 2020

#LeetCode: Implement Trie (Prefix Tree)

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

Trie trie = new Trie();
trie.insert("apple");"apple");   // returns true"app");     // returns false
trie.startsWith("app"); // returns true
trie.insert("app");"app");     // returns true

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

No comments:

Post a Comment

RSSChomp Blog Directory