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

0% completed

Vote For New Content
Solution: Coloring A Border
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

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!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible