Given a 2D board of characters and a word, determine if the word exists in the board.
Rules for word existence:
Constraints:
Examples:
// Example 1:
const board1 = [
["A", "B", "C", "D"],
["S", "A", "A", "T"],
["A", "C", "A", "E"],
];
console.log(exist(board1, "CAT"));
// Output: true
// Explanation: Can form "CAT" using adjacent cells
// Example 2:
const board2 = [
["A", "B", "C", "D"],
["S", "A", "A", "T"],
["A", "C", "A", "E"],
];
console.log(exist(board2, "BAT"));
// Output: false
// Explanation: Cannot form "BAT" using adjacent cells