Back to problems

Count Same-Color Squares in Matrix

Algorithm · Google · Medium

Requirements You are given an $$m \times n$$ grid whose cells have colors. Depending on the version of the prompt, determine either: how many square sub-grids contain cells of one identical color; or the greatest side length among such squares. Examples Example 1 — count variant Input: Output: A single cell forms one square, and all of its cells necessarily have the same color. Example None — count variant Input: Output: There are four $$1 \times 1$$ squares and one $$2…

Checking your access…