Design and implement a Connect Four style game board that supports dropping colored pieces into columns. In this board game, pieces fall vertically under gravity and settle at the lowest available position in the chosen column.
Implement the ConnectFourBoard class:
-
ConnectFourBoard(int rows, int cols)Initializes a game board with the specified number ofrows(height) andcols(width). All cells start empty, represented by the character'0'. -
char[][] drop(char color, int col)Drops a piece of the specifiedcolorinto columncol. The piece falls to the lowest available row in that column. Returns an independent copy of the current board state as a 2D character array after the drop operation.- Empty cells are represented by
'0' - Colored pieces are represented by their characters (e.g.,
'R'for red,'Y'for yellow,'B'for blue) - If the column is already full, the board remains unchanged
- Empty cells are represented by
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected