← Questions

Count identical islands in two grids

0
OpenAICodingLast asked Oct 2024

You get two binary grids of the same size. A region is a group of 1 cells joined up, down, left or right. Count the regions that are exactly the same set of cells in both grids. Find the regions of one grid with BFS or DFS and check each against the other, making sure a match can't extend into extra cells in the second grid.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding