@@ -0,0 +1,2590 @@
+package leetcode.implement_trie_prefix_tree;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aclass TrieNode %7B%0A    char c;%0A    List%3CTrieNode%3E children;%0A    public TrieNode() %7B%0A        children = new ArrayList%3CTrieNode%3E();%0A    %7D%0A%7D%0A%0Apublic class Trie %7B%0A    private TrieNode root;%0A%0A    public Trie() %7B%0A        root = new TrieNode();%0A    %7D%0A%0A    // Inserts a word into the trie.%0A    public void insert(String word) %7B%0A        TrieNode cur = root;%0A        for(char c : word.toCharArray())%7B%0A            TrieNode found = null;%0A            for(TrieNode next : cur.children)%7B%0A                if(next.c == c)%7B%0A                    found = next;%0A                    break;%0A                %7D%0A            %7D%0A            if(found != null)%7B%0A                cur = found;%0A            %7Delse%7B%0A                found = new TrieNode();%0A                found.c = c;%0A                cur.children.add(found);%0A            %7D%0A            cur = found;%0A        %7D%0A        boolean eos = false;%0A        for(TrieNode next : cur.children)%7B%0A            if(next.c == '%5C0')%7B%0A                eos = true;%0A                break;%0A            %7D%0A        %7D%0A        if(!eos)%7B%0A            TrieNode eosNode = new TrieNode();%0A            eosNode.c = '%5C0';%0A            cur.children.add(eosNode);%0A        %7D%0A    %7D%0A%0A    // Returns if the word is in the trie.%0A    public boolean search(String word) %7B%0A        TrieNode cur = root;%0A        for(char c : word.toCharArray())%7B%0A            boolean found = false;%0A            for(TrieNode next : cur.children)%7B%0A                if(next.c == c)%7B%0A                    cur = next;%0A                    found = true;%0A                    break;%0A                %7D%0A            %7D%0A            if(!found)%7B%0A                return false;%0A            %7D%0A        %7D%0A        for(TrieNode eos : cur.children)%7B%0A            if(eos.c == '%5C0')%7B%0A                return true;%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%0A    // Returns if there is any word in the trie%0A    // that starts with the given prefix.%0A    public boolean startsWith(String prefix) %7B%0A        TrieNode cur = root;%0A        for(char c : prefix.toCharArray())%7B%0A            boolean found = false;%0A            for(TrieNode next : cur.children)%7B%0A                if(next.c == c)%7B%0A                    cur = next;%0A                    found = true;%0A                    break;%0A                %7D%0A            %7D%0A            if(!found)%7B%0A                return false;%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%7D%0A%0A// Your Trie object will be instantiated and called as such:%0A// Trie trie = new Trie();%0A// trie.insert(%22somestring%22);%0A// trie.search(%22key%22);%0A

Add java solution for 208. Implement Trie (Prefix Tree)