Word search
Mediumbacktrackingdfsmatrix
board is a grid of letters (one string per row). Return true if word can be spelled from adjacent cells (up/down/left/right) without using the same cell twice.
Example 1
Input: board = ["ABCE","SFCS","ADEE"], word = "ABCCED" Output: true
Example 2
Input: board = ["ABCE","SFCS","ADEE"], word = "ABCB" Output: false
It needs a second B, but the only B is already used.
Constraints
- 1 ≤ rows, cols ≤ 6
- 1 ≤ word.length ≤ 15
- Upper and lower case letters
Submit checks your solution against 9 tests, including hidden ones.
/**
* @param {string[]} board
* @param {string} word
* @return {bool}
*/
function exist(board, word) {
}