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

Method addWord

java/336_Palindrome_Pairs.java:31–48  ·  view source on GitHub ↗
(TrieNode root, String word, int index)

Source from the content-addressed store, hash-verified

29 }
30
31 private void addWord(TrieNode root, String word, int index) {
32 for (int i = word.length() - 1; i >= 0; i--) {
33 int j = word.charAt(i) - 'a';
34
35 if (root.next[j] == null) {
36 root.next[j] = new TrieNode();
37 }
38
39 if (isPalindrome(word, 0, i)) {
40 root.list.add(index);
41 }
42
43 root = root.next[j];
44 }
45
46 root.list.add(index);
47 root.index = index;
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++) {

Callers 1

palindromePairsMethod · 0.95

Calls 2

isPalindromeMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected