Press "Enter" to skip to content

Posts tagged as “children”

花花酱 LeetCode 208. Implement Trie (Prefix Tree)

Problem:

Implement a trie with insertsearch, and startsWith methods.

Note:
You may assume that all inputs are consist of lowercase letters a-z.

Idea:




Tree/children array

 

 

Solution:

C++ / Array

 

C++ / hashmap

 

Java

 

Python 1:

 

Python 2: