0
0
DSA Typescriptprogramming~10 mins

Word Search in Grid Using Backtracking in DSA Typescript - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to check if the current cell matches the current character of the word.

DSA Typescript
if (board[row][col] === [1]) {
Drag options to blanks, or click blank then click option'
Aword
Bword[index]
Cword.length
Dword[0]
Attempts:
3 left
💡 Hint
Common Mistakes
Using word[0] instead of word[index]
Comparing with the whole word instead of a single character
2fill in blank
medium

Complete the code to mark the current cell as visited.

DSA Typescript
visited[row][col] = [1];
Drag options to blanks, or click blank then click option'
Afalse
Bnull
Ctrue
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Marking visited as false instead of true
Not marking visited at all
3fill in blank
hard

Fix the error in the recursive call to explore neighbors by filling the correct row offset.

DSA Typescript
if (dfs(board, word, row + [1], col, index + 1, visited)) {
Drag options to blanks, or click blank then click option'
A0
Bindex
C-1
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 does not move to a neighbor
Using index instead of a row offset
4fill in blank
hard

Fill both blanks to check boundaries and if the cell is already visited.

DSA Typescript
if (row < 0 || row >= board.length || col < 0 || col >= board[0].length || visited[[1]][[2]]) { return false; }
Drag options to blanks, or click blank then click option'
Arow
Bcol
Cindex
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using index or word instead of row and col
Checking visited outside the board boundaries
5fill in blank
hard

Fill all three blanks to explore all four directions (up, down, left, right) in the DFS.

DSA Typescript
return dfs(board, word, row + [1], col + [2], index + 1, visited) || dfs(board, word, row + [3], col, index + 1, visited) || dfs(board, word, row, col + 1, index + 1, visited) || dfs(board, word, row, col - 1, index + 1, visited);
Drag options to blanks, or click blank then click option'
A1
B-1
C0
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing row and column offsets
Using index instead of numeric offsets