Optimal Algorithmic Approach
DFS flood fill with color-match condition.
Core Invariants & Edge Cases
- DFS/BFS from the starting cell
- Only spread to cells with the same original color
- Guard against infinite recursion if newColor == oldColor
Recolor a connected region in a 2D grid starting from a given pixel.
DFS flood fill with color-match condition.
Coding interviews are only 50% of the bar. Master High-Level Design, distributed systems, and Object-Oriented LLD.