(String keyword)
| 13 | |
| 14 | // Step 1: Build the Trie |
| 15 | public void addKeyword(String keyword) { |
| 16 | TrieNode currentNode = root; |
| 17 | for (char c : keyword.toCharArray()) { |
| 18 | currentNode = currentNode.children.computeIfAbsent(c, k -> new TrieNode()); |
| 19 | } |
| 20 | currentNode.output.add(keyword); |
| 21 | } |
| 22 | |
| 23 | // Step 2: Build Failure Links |
| 24 | public void buildFailureLinks() { |