MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / findWords

Method findWords

java/0212-word-search-ii.java:7–24  ·  view source on GitHub ↗
(char[][] board, String[] words)

Source from the content-addressed store, hash-verified

5 private Trie currentTrie;
6
7 public List<String> findWords(char[][] board, String[] words) {
8 Trie root = new Trie();
9 for (String word : words) {
10 root.addWord(word);
11 }
12
13 ROWS = board.length;
14 COLS = board[0].length;
15 HashSet<String> res = new HashSet<>();
16 HashSet<String> visit = new HashSet<>();
17
18 for (int r = 0; r < ROWS; r++) {
19 for (int c = 0; c < COLS; c++) {
20 dfs(r, c, root, "", res, visit, board, root);
21 }
22 }
23 return new ArrayList<>(res);
24 }
25
26 public void dfs(
27 int r,

Callers

nothing calls this directly

Calls 2

addWordMethod · 0.95
dfsMethod · 0.95

Tested by

no test coverage detected