Link -> Replace O's with X's
- Observe the pattern carefully, You will notice that the elements connected with boundary elements must not be converted, as boundary elements dissatisfy the argument that top, bottom, left and right must be 'X'
- Traverse the border elements and is element is 'O', use dfs and find all the connected nodes.
- Once we know which elements will not be converted, we convert the rest.
- Hurray! Done.