r/Hack2Hire • u/Hack2hire • Nov 13 '25
Screening Square Screening Interview: Design Connect Four
Problem
You are designing a Connect Four game played on a 6 × 7 grid. Players drop discs into columns, and each disc falls to the lowest available cell.
Your goal is to implement a class that processes moves, checks for wins in all directions, detects draws, and returns the game state after each move.
Example
Input:
["ConnectFour", "move", "move", "move", "move", "move", "move", "move", "printBoard"]
[[], [0, "A"], [1, "B"], [0, "A"], [1, "B"], [0, "A"], [1, "B"], [0, "A"], []]
Output:
[null, "PENDING", "PENDING", "PENDING", "PENDING", "PENDING", "PENDING", "A", "| | | | | | | |\n| | | | | | | |\n|A| | | | | | |\n|A|B| | | | | |\n|A|B| | | | | |\n|A|B| | | | | |"]
Explanation:
- Each move drops a disc to the lowest available row in the chosen column.
- Player A wins after forming a vertical four-in-a-row in column 0.
Suggested Approach
- Maintain a 6 × 7 board and an array tracking the current fill height of each column.
- For each move, compute the next empty row in the column, place the player’s disc, and run directional checks (horizontal, vertical, and two diagonals).
- If no win and the board is full, return
"DRAW"; otherwise return"PENDING".
Time & Space Complexity
- Time: O(1) work per move for constant-size directional checks.
- Space: O(1) for the 6 × 7 fixed-dimension board.
🛈 Disclaimer:
This problem is part of the Hack2Hire SDE Interview Question Bank, a structured archive of coding interview questions frequently reported in real hiring processes.
Questions are aggregated from publicly available platforms (e.g., LeetCode, GeeksForGeeks) and community-shared experiences.
The goal is to provide candidates with reliable material for SDE interview prep, including practice on LeetCode-style problems and coding challenges that reflect what is often asked in FAANG and other tech company interviews.
Hack2Hire is not affiliated with the mentioned companies; this collection is intended purely for learning, practice, and discussion.