GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Given a m*n matrix with LEDs, having each cell representing the state of the LED as either ON(1)or OFF(0).

Given a m*n matrix with LEDs, having each cell representing the state of the LED as either ON(1)or OFF(0). Given a cell position, state of all the adjacent (in all 8 direction) cells sharing the same state as the given cell toggles and the effect cascades. Represent the final state of the matrix

Source - http://www.geeksforgeeks.org/amazon-interview-experience-set-225-for-1-year-experienced/

It looks like that it can be done by doing DFS/BFS . This line "Given a cell position, state of all the adjacent (in all 8 direction) cells sharing the same state as the given cell toggles and the effect cascades" is not clear to me .

asked Sep 8, 2015 by codersx

The same thing isn't clear to me.. the change due to cascading effect on adjacent to adjacent cells depends on which cell adjacent cell we choose first to propagate the effect. The question seems completely absurd without a proper example.

...