Let\'s take this map, where \'#\' illustrates a taken square and \'.\' illustrates a free square:
1 . # # # . . 2 . # . . # . 3 # . . . . # 4 . # # # . . 5 . . . . .
I think this question can be reduced to a convex hull problem if we consider each # as point x,y then convex hull be give us the x,y of all the # which are absent
http://en.wikipedia.org/wiki/Convex_hull
I will try to code it in leisure ..