MCPcopy
hub / github.com/qiyuangong/leetcode / search

Method search

java/336_Palindrome_Pairs.java:50–64  ·  view source on GitHub ↗
(String[] words, int i, TrieNode root, List<List<Integer>> res)

Source from the content-addressed store, hash-verified

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) {

Callers 1

palindromePairsMethod · 0.95

Calls 2

isPalindromeMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected