You are given an 8×8 chessboard, where:
• 'R' → white rook (exactly one)
• 'B' → white bishop
• 'p' → black pawn
• '.' → empty square
The rook can move horizontally or vertically any number of squares until:
• It hits another piece, or
• It reaches the edge of the board.
A rook can capture a pawn 'p' if it can move to that pawn’s square in one move without any other piece blocking the way.
Your task is to return the number of pawns that the rook can capture.
Input: board = [ [".",".",".",".",".",".",".","."], [".","p","p","p","p","p",".","."], [".","p","p","B","p","p",".","."], [".","p","B","R","B","p",".","."], [".","p","p","B","p","p",".","."], [".","p","p","p","p","p",".","."], [".",".",".",".",".",".",".","."], [".",".",".",".",".",".",".","."] ]
Output: 0
Input: board = [ [".",".",".",".",".",".",".","."], [".",".",".","p",".",".",".","."], [".",".",".","R",".",".",".","p"], [".",".",".",".",".",".",".","."], [".",".",".",".",".",".",".","."], [".",".",".","p",".",".",".","."], [".",".",".",".",".",".",".","."], [".",".",".",".",".",".",".","."] ]
Output: 3
Accepted:
Submission: