Practice/Microsoft/Design a Connect Four Game
Object Oriented DesignMust
Design the core validation logic for a disc-drop style board game. In this two-player game, participants take turns dropping colored discs into a vertical grid. The discs fall to the lowest available position in the selected column. A player wins by forming an unbroken line of four of their discs either horizontally, vertically, or diagonally.
Your task is to implement a function that determines whether a given player has achieved a winning configuration on the board.
true if the player has won, false otherwiseExample 1: Horizontal Win
Input: rows = 6, cols = 7 moves = [[5,2], [5,3], [5,4], [5,5]] player = "R" Output: true Explanation: Player R has four discs in a row horizontally at the bottom row
Example 2: Vertical Win
Input: rows = 6, cols = 7 moves = [[5,3], [4,3], [3,3], [2,3]] player = "B" Output: true Explanation: Player B has four discs stacked vertically in column 3
Example 3: Diagonal Win
Input: rows = 6, cols = 7 moves = [[5,1], [4,2], [3,3], [2,4]] player = "R" Output: true Explanation: Player R has four discs on an ascending diagonal line
Example 4: No Win Yet
Input: rows = 6, cols = 7 moves = [[5,0], [5,1], [5,2]] player = "B" Output: false Explanation: Player B only has three discs in a row, not four