Another example


  • 0
    P

    Could someone give me another example of the question -solution relation? I don't seem to understand the problem.
    Given:

    X X X X    
    X O O X
    X X O X
    X O X X
    

    how can we disregard '0' at [1,1]? It is clearly not surrounded by all 'X'.


  • 5
    M

    That means if a group of 'O' are exactly surrounded by 'X', then all 'O' in this group will be changed to 'X'
    So these 'O': [1,1], [1,2], [2,2] are belong to one group, because they are connected
    The last one 'O': [3,1] is another group.


  • 0
    P

    But still, wouldn't it for the group to be surrounded by all X-s, character at [3,1] be 'X', not 'O'?


  • 0
    M

    'O' group at [3,1] is not surrounded entirely by 'X', because it is at the edge of matrix, so there is not 'X' below [3,1], It is still 'O' , not 'X'.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.