Implement Connect Four Winner Detection
Company: Virtu
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates the ability to design and implement game-state logic for a Connect Four-style board, covering board data structures, coordinate and boundary handling, gravity-based token placement, and efficient pattern detection for consecutive tokens in the Coding & Algorithms domain.
Constraints
- Players alternate starting with player 1
Examples
Input: ([0, 0, 1, 1, 2, 2, 3],)
Expected Output: 7
Explanation: Player 1 wins horizontally on move 7.
Input: ([0, 1, 0, 1, 0, 1, 0],)
Expected Output: 7
Explanation: Player 1 wins vertically.
Input: ([0, 1, 2],)
Expected Output: 0
Explanation: No winner yet.
Input: ([0, 0, 0, 0, 0, 0, 0],)
Expected Output: -1
Explanation: Column overflow is invalid before a win for player 1.
Hints
- Only lines through the latest placed token need checking.