Implement a function to solve the Word Search problem on a grid (given a 2D grid of characters, find if a word exists)
HardProblem Statement
Implement a function to solve the Word Search problem on a grid (given a 2D grid of characters, find if a word exists)
Sample Input
board = [['A', 'B', 'C', 'E'], ['S', 'F', 'C', 'S'], ['A', 'D', 'E', 'E']] word = 'ABCCED'
Sample Output
true
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
import java.util.*;
public class Main {
public static boolean exist() {
char[][] board = {
{'A', 'B', 'C', 'E'},
{'S', 'F', 'C', 'S'},
{'A', 'D', 'E', 'E'}
};
String word = "ABCCED";
// Your code here
return false;
}
}
Input
board = [['A', 'B', 'C', 'E'], ['S', 'F', 'C', 'S'], ['A', 'D', 'E', 'E']] word = 'ABCCED'
Expected Output
true