(String[] words, int i, TrieNode root, List<List<Integer>> res)
| 48 | } |
| 49 | |
| 50 | private void search(String[] words, int i, TrieNode root, List<List<Integer>> res) { |
| 51 | for (int j = 0; j < words[i].length(); j++) { |
| 52 | if (root.index >= 0 && root.index != i && isPalindrome(words[i], j, words[i].length() - 1)) { |
| 53 | res.add(Arrays.asList(i, root.index)); |
| 54 | } |
| 55 | |
| 56 | root = root.next[words[i].charAt(j) - 'a']; |
| 57 | if (root == null) return; |
| 58 | } |
| 59 | |
| 60 | for (int j : root.list) { |
| 61 | if (i == j) continue; |
| 62 | res.add(Arrays.asList(i, j)); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | private boolean isPalindrome(String word, int i, int j) { |
| 67 | while (i < j) { |
no test coverage detected