MCPcopy
hub / github.com/doocs/leetcode / dfs

Method dfs

solution/0400-0499/0425.Word Squares/Solution.java:50–66  ·  view source on GitHub ↗
(List<String> t)

Source from the content-addressed store, hash-verified

48 }
49
50 private void dfs(List<String> t) {
51 if (t.size() == words[0].length()) {
52 ans.add(new ArrayList<>(t));
53 return;
54 }
55 int idx = t.size();
56 StringBuilder pref = new StringBuilder();
57 for (String x : t) {
58 pref.append(x.charAt(idx));
59 }
60 List<Integer> indexes = trie.search(pref.toString());
61 for (int i : indexes) {
62 t.add(words[i]);
63 dfs(t);
64 t.remove(t.size() - 1);
65 }
66 }
67}

Callers 1

wordSquaresMethod · 0.95

Calls 7

lengthMethod · 0.80
sizeMethod · 0.45
addMethod · 0.45
appendMethod · 0.45
searchMethod · 0.45
toStringMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected