Leetcode 1559. Detect Cycles in 2D Grid
Determine whether any connected region of identical letters in the m x n grid contains a cycle of length ≥4 formed by adjacent (up/down/left/right) moves. Treat the grid as an undirected graph and detect a back-edge (ignoring the immediate parent to avoid trivial two-node backtracks) using DFS/BFS in O(mn) time.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Your account is free and you can post anonymously if you choose.