Word Search
Given a 2D board and a word, find if the word exists in the grid.
题意很简单,给你一个二维字母的数组,可以上下左右走,查找是否某个单词是否存在。同一位置的字母不可以被使用多次。
代码
public class Solution {
static boolean[][] visited;
public boolean exist(char[][] board, String word) {
visited = new boolean[board.length][board[0].length