(String word)
| 25 | TrieNode root = new TrieNode(); |
| 26 | |
| 27 | void insert(String word) { |
| 28 | TrieNode current = root; |
| 29 | for (int i = 0; i < word.length(); i++) { |
| 30 | char c = word.charAt(i); |
| 31 | if (!current.hasChild(c)) { |
| 32 | current.children[c - 'a'] = new TrieNode(); |
| 33 | } |
| 34 | current = current.getChild(c); |
| 35 | } |
| 36 | current.isEnd = true; |
| 37 | } |
| 38 | |
| 39 | boolean checkWord(String word) { |
| 40 | TrieNode current = root; |