Largest color region

Write code · Medium · §9.2 Walking a grid

A piece of pixel art to use as a profile picture is given as the grid picture. picture[r][c] is the color of the cell in row r, column c, written as one uppercase English letter. Cells of the same color that touch each other above, below, left, or right form one region. Cells that touch only diagonally do not count as touching.

Complete the function solution, which returns the number of cells in the largest region.

Function

solution(picture)

Constraints

Examples

pictureresult
['AAB', 'CAB', 'CCC']4
['ABBB', 'AACB', 'CCCB', 'DDDD']5

Starter code

def solution(picture):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.