Detect Cycles in 2D Grid
Join neighbouring cells that hold the same letter in a union-find; a join between two cells already in one set closes a cycle.
Join neighbouring cells that hold the same letter in a union-find; a join between two cells already in one set closes a cycle.