Approach hintTry it first, then revealHide
Run a DFS over cells of the same colour while remembering the cell you came from. Reaching an already visited cell other than that parent reveals a cycle, and on a grid such a cycle has at least four cells.
Run a DFS over cells of the same colour while remembering the cell you came from. Reaching an already visited cell other than that parent reveals a cycle, and on a grid such a cycle has at least four cells.