MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / solve

Method solve

Array/SurroundedRegions.py:68–117  ·  view source on GitHub ↗

:type board: List[List[str]] :rtype: void Do not return anything, modify board in-place instead.

(self, board)

Source from the content-addressed store, hash-verified

66 # return False
67
68 def solve(self, board):
69 """
70 :type board: List[List[str]]
71 :rtype: void Do not return anything, modify board in-place instead.
72 """
73 # return board
74
75 if not board:
76 x_length = 0
77 else:
78 x_length = len(board[0])
79 y_length = len(board)
80
81 def translate_o_to_e(x, y):
82 # pass
83 # coordinate = self.makeAround(x, y)
84 # if coordinate:
85 for i in self.makeAround(x, y):
86 if i[0] >= 0 and i[1] >= 0 and i[0] < y_length and i[1] < x_length:
87 if board[i[0]][i[1]] == "O":
88 board[i[0]][i[1]] = "E"
89 translate_o_to_e(i[1], i[0])
90
91 # up down
92 e_coordinate = []
93 for i in range(x_length):
94 if board[0][i] == 'O':
95 board[0][i] = 'E'
96 translate_o_to_e(i, 0)
97
98 if board[y_length-1][i] == "O":
99 board[y_length-1][i] = 'E'
100 translate_o_to_e(i, y_length-1)
101
102 # left right
103 for i in range(y_length):
104 if board[i][0] == 'O':
105 board[i][0] = 'E'
106 translate_o_to_e(0, i)
107
108 if board[i][x_length-1] == 'O':
109 board[i][x_length-1] = 'E'
110 translate_o_to_e(x_length-1, i)
111
112 for y in range(y_length):
113 for x in range(x_length):
114 if board[y][x] == 'E':
115 board[y][x] = 'O'
116 elif board[y][x] == 'O':
117 board[y][x] = 'X'
118
119# e_coordinate = []
120# for y in range(y_length):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected