Q) We are given a 2D grid of characters. Count the number of non-overlapping square subgrids that meet these conditions:
-
A square is any k x k region (with k ≥ 1) of the same character.
-
The entire square must be made of only that character.
-
No cell in a square should be connected to any same-letter cell outside the square (no same-letter leakage).
-
No overlapping: Once a cell is used in a square, it cannot be reused.
I was asked this problem today but sadly was not able to code the full solution but it was fun. Is there any similar problem available on leetcode?
Comments (11)


