[Puzzle Game]Finding Combination of squares in a 2D Grid

I am making a game like Lumines Remastered (Lumines Remastered Nintendo Switch Gameplay - YouTube) and I was pretty much successful in it. But, I got stuck in one place in clearing the pieces.

I have a 2d Array grid of 16x10 and each individual pieces are stored in it.

I was successful in finding all the matching pieces using the flood fill algorithm and storing every same color matching pieces in a separate list. Now, the condition is I only want to delete the pieces that are in combination of squares with others and not the individual ones.

For example:-

Like this. 1 is in square combination and I only want to delete them.

But,

2 in this image is also a valid square (so, 1 & 2 combined should get deleted). I quite can’t seem to figure out how to check for square combination. Any suggestions and ideas would be great.

So you want to find 2x2 squares which are made of the same color and allow overlaps? Since you want allow overlaps you just have to do a scan and mark procedure. Just iterate through all of your tiles. For each tile you compare it to the tile x+1 , also the tile y+1 and finally x+1 and y+1. If they are all the same just mark those 4 tiles for removal. If you do that for every tile you get all tiles marked which are part of a 2x2 square. Watch out to stay in bound when doing “+1” in any direction. The last column doesn’t need to be checked since the tiles in the second last column would check them implicitly.