This question evaluates understanding of DFS and backtracking for grid traversal and combinatorial generation, assessing skills in graph traversal, recursion, connected-component counting, and mapping digit sequences to letter combinations.
You may be asked to solve one or more DFS/backtracking problems:
m x n
grid where
1
represents land and
0
represents water, count how many connected land regions exist. Cells are connected horizontally and vertically.
2 -> abc
,
3 -> def
,
4 -> ghi
,
5 -> jkl
,
6 -> mno
,
7 -> pqrs
,
8 -> tuv
,
9 -> wxyz
.
2345
, generate all possible letter strings it can represent.
Explain your approach, edge cases, and time/space complexity.