(String word)
| 37 | } |
| 38 | |
| 39 | boolean checkWord(String word) { |
| 40 | TrieNode current = root; |
| 41 | for (int i = 0; i < word.length(); i++) { |
| 42 | char c = word.charAt(i); |
| 43 | if (current.hasChild(c)) { |
| 44 | current = current.getChild(c); |
| 45 | } else { |
| 46 | return false; |
| 47 | } |
| 48 | } |
| 49 | return current.isEnd; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | class TrieNode { |