You are given an board representing a chessboard containing empty squares and chess pieces:
Exactly 'R'
Zero or more white bishops denoted by 'B'
Zero or more black pawns denoted by 'p'
Empty squares denoted by '.'
A rook can move any number of squares horizontally or vertically across four directions (up, down, left, and right) until it reaches the edge of the board or another piece:
If the rook encounters a black pawn 'p', it can capture that pawn, and movement in that direction terminates.
If the rook encounters a white bishop 'B', its movement is blocked, and it cannot capture any piece further in that direction.
Return the total number of pawns the rook can capture.
Constraints:
board.length
board[i].length
board[i][j] is either 'R', '.', 'B', or 'p'
There is exactly board[i][j] == 'R'
You are given an board representing a chessboard containing empty squares and chess pieces:
Exactly 'R'
Zero or more white bishops denoted by 'B'
Zero or more black pawns denoted by 'p'
Empty squares denoted by '.'
A rook can move any number of squares horizontally or vertically across four directions (up, down, left, and right) until it reaches the edge of the board or another piece:
If the rook encounters a black pawn 'p', it can capture that pawn, and movement in that direction terminates.
If the rook encounters a white bishop 'B', its movement is blocked, and it cannot capture any piece further in that direction.
Return the total number of pawns the rook can capture.
Constraints:
board.length
board[i].length
board[i][j] is either 'R', '.', 'B', or 'p'
There is exactly board[i][j] == 'R'