You are given an board representing a game board, where '.' denotes an empty cell, 'W' denotes a white piece, and 'B' denotes a black piece. You are also given integers rMove and cMove indicating the coordinates of an empty cell, and a character color representing the color of the piece to place at (rMove, cMove).
A move is considered legal if placing a piece of color color at cell (rMove, cMove) creates at least one good line where (rMove, cMove) is one of the endpoints.
A sequence of cells forms a good line if:
The line consists of at least
Both endpoints of the line contain pieces of color color.
Every cell between the two endpoints contains a piece of the opposite color (neither empty '.' nor color).
Return true if the move is legal, or false otherwise.
Constraints:
board.length board[r].length
rMove, cMove
board[rMove][cMove] '.'
color is either 'B' or 'W'
You are given an board representing a game board, where '.' denotes an empty cell, 'W' denotes a white piece, and 'B' denotes a black piece. You are also given integers rMove and cMove indicating the coordinates of an empty cell, and a character color representing the color of the piece to place at (rMove, cMove).
A move is considered legal if placing a piece of color color at cell (rMove, cMove) creates at least one good line where (rMove, cMove) is one of the endpoints.
A sequence of cells forms a good line if:
The line consists of at least
Both endpoints of the line contain pieces of color color.
Every cell between the two endpoints contains a piece of the opposite color (neither empty '.' nor color).
Return true if the move is legal, or false otherwise.
Constraints:
board.length board[r].length
rMove, cMove
board[rMove][cMove] '.'
color is either 'B' or 'W'