The case of the rectangle and the round circle are very different.
If you are looking for the best rectangular area, your brute force approach O(nk) (n = total number of tiles, k = number of tiles within a region) that can easily be improved to O(n) by caching partial sums along rows / columns is the best that you can do, since you must look at each plate at least once. If you need to do this often, with changing regions or tiles, the spatial data structure will be faster than O (n), due to some initial configuration.
For the case of a circle, if the center of the circle is bounded by the edges of the tile, I'm not sure how you will improve your brute force algorithm O(nk) .
However, if the circle can really be anywhere, as you said, you cannot naively go through all possible round positions, because there are infinite possible positions!
Instead, you need something smarter; see, for example, this answer (consider the center of each tile as a weighted point). Note that since the points are weighted, you should keep in mind that the best circle can only have one point!
source share