MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / exist

Method exist

79-word-search/word-search.java:5–18  ·  view source on GitHub ↗
(char[][] board, String word)

Source from the content-addressed store, hash-verified

3 private int[][] directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
4
5 public boolean exist(char[][] board, String word) {
6 int m = board.length;
7 int n = board[0].length;
8 visited = new boolean[m][n];
9
10 for (int i = 0; i < m; i++) {
11 for (int j = 0; j < n; j++) {
12 if (dfs(board, word, i, j, 0)) {
13 return true;
14 }
15 }
16 }
17 return false;
18 }
19
20 private boolean dfs(char[][] board, String word, int i, int j, int index) {
21 if (index == word.length()) {

Callers

nothing calls this directly

Calls 1

dfsMethod · 0.95

Tested by

no test coverage detected