Let\'s take this map, where \'#\' illustrates a taken square and \'.\' illustrates a free square:
1 . # # # . . 2 . # . . # . 3 # . . . . # 4 . # # # . . 5 . . . . .
If you model this map as a graph, and each square is connected to its four neighbours, you can use a bridge finding algorithm to find the square you need.
Note this model gives you several subgraphs to work with sometimes, so it might produce a number of false positives around the border, since adding a #
there would certainly separate some nodes from the rest. To get around this, you could pad two levels of squares around the graph, so that no single #
could separate a border node from the rest.
@svick's comment inspired this method.