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

Method dfs

solution/0400-0499/0472.Concatenated Words/Solution.java:34–50  ·  view source on GitHub ↗
(String w)

Source from the content-addressed store, hash-verified

32 }
33
34 private boolean dfs(String w) {
35 if ("".equals(w)) {
36 return true;
37 }
38 Trie node = trie;
39 for (int i = 0; i < w.length(); ++i) {
40 int idx = w.charAt(i) - 'a';
41 if (node.children[idx] == null) {
42 return false;
43 }
44 node = node.children[idx];
45 if (node.isEnd && dfs(w.substring(i + 1))) {
46 return true;
47 }
48 }
49 return false;
50 }
51}

Callers 1

Calls 2

lengthMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected