O68

Word Search in Grid

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: BOOLEAN

Problem Statement & Objective

Given an m x n grid of characters board and a string word, return True if word exists in the grid.

Function Signature (Python)

exist_word(board: list[list[str]], word: str) -> bool

Input & Output Contract

Output Rule:True veya False.

System Constraints

m == tahta.length, n == tahta[i].length
1 <= m, n <= 6
1 <= kelime.length <= 15
tahta ve kelime büyük/küçük İngilizce harfler içerir

Example Execution Walkthrough

tahta = [['A','B','C','E'],['S','F','C','S'],['A','D','E','E']], kelime = 'ABCCED' -> True
kelime = 'ABCB' -> 'B' iki kez kullanılamaz -> False

Example Test Scenarios (3)

Example 1
Input:[[["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]],"ABCCED"]
Expected Output:true
Example 2
Input:[[["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]],"SEE"]
Expected Output:true
Example 3: Tekrar Kullanım
Input:[[["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]],"ABCB"]
Expected Output:false
Loading Python Editor...
Input Parameters
[
  [
    [
      "A",
      "B",
      "C",
      "E"
    ],
    [
      "S",
      "F",
      "C",
      "S"
    ],
    [
      "A",
      "D",
      "E",
      "E"
    ]
  ],
  "ABCCED"
]
Expected Output
true