public void insert(String word) {
            TrieNode ptr = root;
            for (char c : word.toCharArray()) {
                if (ptr.children[c - 'a'] == null) {
                    ptr.children[c - 'a'] = new TrieNode();
                }
                ptr = ptr.children[c - 'a'];
            }
            ptr.end = true;
        }