# Can't understand the output of last test case

• def turnRow(cRow,lastRow,width):
# turn string to list which mutable
helpRow=list(cRow)

``````#release by lastRow

for i in xrange(width):

if(i==0 and helpRow[i]=='O'):
helpRow[i]='T'

if(i==width-1 and helpRow[i]=='O'):
helpRow[i]='T'

if(lastRow[i]=='T' and helpRow[i]=='O'):
helpRow[i]='T'

for i in xrange(1,width):
if(helpRow[i-1]=='T' and helpRow[i]=='O'):
helpRow[i]='T'

for i in xrange(width-2,-1,-1):
if(helpRow[i+1]=='T' and helpRow[i]=='O'):
helpRow[i]='T'

return ''.join(helpRow)
``````

class Solution:
# @param board, a 2D array
# Capture all regions by modifying the input board in-place.
# Do not return any value.
def solve(self, board):

``````    #here,we use one simple idea three label: T true alread proof is free
#'X' has no change
#'O' waiting for consideration

height=len(board)
if(height<=1):
return board

lastRow=board[-1]
width=len(lastRow)
helpRow="T"*width

for i in xrange(width):
cRow=board[i]
helpRow=turnRow(cRow,helpRow,width)
board[i]=helpRow

helpRow="T"*width

for i in xrange(width-1,-1,-1):
cRow=board[i]
helpRow=turnRow(cRow,helpRow,width)
board[i]=helpRow

for i in xrange(width):
crow=board[i]
crow=crow.replace("O","X")
crow=crow.replace("T","O")
board[i]=crow

return board
``````

expected result of board[17] :OOOOOOXOOOXOXOXXOXXX
while input of board[17]:OOOOOOXOOOXOXOXXXXXX how can it happen !!!!

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