Grokking Graph Algorithms for Coding Interviews
Ask Author
Back to course home

0% completed

Vote For New Content
Solution: Coloring A Border
On this page

Problem Statement

You are given an m x n integers grid, and three integers row, col, and color. Each cell in the grid has a color value represented by an integer.

Two cells are adjacent if they share a side. Cells with the same color and connected through adjacent cells form a connected component.

Color the border of the connected component that includes the cell at grid[row][col] with the new color provided. The border of a connected component consists of cells that are either adjacent to a cell with a different color or lie on the boundary of the grid.

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page