Back
Word Search II
Given an m x n board of characters and a list of strings words, return all words on the board.
Java
Description
Solution
My Code
Word Search II
Given an m x n board of characters and a list of strings words, return all words on the board.
Example 1:
Input:
{"board":[["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]],"words":["oath","pea","eat","rain"]}
Output:
["eat","oath"]
Viz
Tests
Run
Input
LeetCode Example
Small Board
Custom
{"board":[["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]],"words":["oath","pea","eat","rain"]}
arr =
{"board":[["o","a","a","n"],["e","t","a","e"],["i","h","k","r"],["i","f","l","v"]],"words":["oath","pea","eat","rain"]}
prefix
found
[]
o
0,0
a
0,1
a
0,2
n
0,3
e
1,0
t
1,1
a
1,2
e
1,3
i
2,0
h
2,1
k
2,2
r
2,3
i
3,0
f
3,1
l
3,2
v
3,3
active
path
visited
Trie Visualization
e
o
p
r
a
a
e
a
t
t
a
i
h
n
Variables
Variable
Value
R
4
C
4
words
oath,pea,eat,rain
board
Matrix(4x4)
found
[]
Depth
Function Call
1
findWords(board, words)
0/233
0.5x
1x
2x
4x