Given an m by n matrix of characters and a list of strings,
return the strings that are found in the m by n matrix.
Example:
Matrix:
[
['a', 'b', 'c'],
['d', 'e', 'f']
]
Words:
['abe', 'xyz', 'abf']
Output:
[‘abe’]
This problem asks you to check which of the given words can be found in a 2D character matrix. A valid word must be formed by adjacent characters in the matrix, typically in horizontal or vertical directions (depending on the interviewer’s clarification).
The task is essentially a simplified version of Word Search / Word Search II.
Core challenges:
For each word, you must scan the matrix to find its starting character.
Then use DFS/BFS to verify whether the entire word can be formed.
Handle visited paths so letters can’t be reused.
Optimize by pruning early and avoiding repeated searches.
This is a typical recursion + backtracking problem testing matrix traversal and search optimization.
The VOprep team has long accompanied candidates through various major company OAs and VOs, including SnowFlake, Google, Amazon, Citadel, SIG, providing real-time voice assistance, remote practice, and interview pacing reminders to help you stay smooth during critical moments. If you are preparing for these companies, you can check out our customized support plans—from coding interviews to system design, we offer full guidance to help you succeed.