As reported: Samsung Ads team, coding round (2026): find the word "JOY" in a 2D character grid and return true if it is present; working code, test cases, and time and space complexity were expected.
Given an m x n grid of characters board and a string word, return true if word exists in the grid.
The word is built from letters of sequentially adjacent cells — horizontally or vertically neighbouring. The same cell may not be used more than once in one word.
This is LeetCode 79 — Word Search.
Example 1
board = S A M S U N
G J X Y O E
Q O W J O X
P Y W U T C
word = "JOY" -> true J (row 1, col 1) -> O (row 2, col 1) -> Y (row 3, col 1), going down
Example 2
board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED" -> true
Example 3
same board, word = "ABCB" -> false (B would have to be reused)
Constraints: 1 ≤ m, n ≤ 6; 1 ≤ word.length ≤ 15; letters are English upper- and lower-case.
Code runner format: two lines: the board as a JSON array of arrays of one-character strings, then the word as a JSON string. Implement exist(board, word); the harness prints true or false.