Implement Connect Four with bottom push-up
Company: Jane Street
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Take-home Project
Implement a Connect Four variant where when a player inserts a disc into a column, the disc moves to the bottom cell of that column and pushes all existing discs in that column up by one. If the column is already full, the disc that is pushed above the top row is ejected and removed from the board. Design the board representation and APIs to:
(
1) initialize with R rows and C columns (default 6x
7),
(
2) drop a disc for a given player into a column,
(
3) detect a win (four in a row horizontally, vertically, or diagonally) after each move, and
(
4) support undo and redo of moves. Specify time and space complexities, data structures used, and how you handle edge cases such as ejected discs, invalid columns, alternating turns, and draw detection. Provide code for the core operations.
Quick Answer: This question evaluates proficiency in data structures, algorithm design, state management, and API design for game mechanics, focusing on board representation, move operations, win detection, and undo/redo functionality.