Chambers In A Castle Algorithm
- by 7Aces
Problem Statement -
Given a NxM grid of 1s & 0s (1s mark walls, while 0s indicate empty chambers), the task is to identify the number of chambers & the size of the largest. And just to whet my curiosity, to find in which chamber, a cell belongs.
It seems like an ad hoc problem, since the regular algorithms just don't fit in. I just can't get the logic for writing an algorithm for the problem. If you get it, pseudo-code would be of great help!
Note - I have tried the regular grid search algorithms, but they don't suffice the problem requirements.
Source - INOI Q Paper 2003