I’m looking for an algorithm that can quickly find rectangles of 0‘s in a matrix with random digits 0-9 that are not smaller than X and Y in lengths.
My own just scans for 0’s and looks if there is an adjacent rectangle, if not, continues. It’s rather slow, so maybe there is something quicker.
Create a table with the same size as the original. Sweep original vertically and count the number of consecutive zeros above and including the current field, write this into the new table.
Sweep original table horizontally count the number of consecutive zeros left of and including the current field. Then for each field those two numbers tell you the size of the rectangle ending at that field.
The rest of the solution depends on parts of the question you didn’t specify. Perhaps you can simply output them whenever they’re large enough, perhaps you need to add some test to check if you’re at the bottom right corner of a rectangle.