Grofers OA

Find the maximum area of water that is be stored in between a grid of buildings.
The grid is (n*m) . building are denoted by " % “and water by " @”
Also if the water is on the edges of the grid then that amount of water has not to be counted.
all the buildings are of width 1
Example
5 7
%%%%%%%
%%%%%%%
%@@%%@@
%%%%%@@
%%%%%%%
%@@@%%
%%%%%%%
answer 3
as first water storage is 2 units…
second is 4 but is on the edge
3rd is 3 units…
so answer is 3.