PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Airbnb

Implement Connect Four with win detection

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's ability to design efficient data structures and algorithms for real-time game state management, including win detection, API design, time/space complexity analysis, and handling edge cases such as full or out-of-range columns.

  • Medium
  • Airbnb
  • Coding & Algorithms
  • Software Engineer

Implement Connect Four with win detection

Company: Airbnb

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Take-home Project

Implement a Connect Four game engine. Support a general m×n board (default 6× 7) and a win condition of k in a row (default 4). Provide an API: ConnectFour(m, n, k), move(column, player)->status where status returns 0 (no win), 1 or 2 (player wins), -1 (invalid move), and a separate method isDraw(). Discs fall to the lowest available cell in the chosen column. After each move, detect wins horizontally, vertically, and both diagonals. Design data structures to achieve O( 1) or near O( 1) time per move for win checking, and analyze time/space complexity. Extend the design to support reset() and optional undo() efficiently, and discuss how you would test edge cases (full columns, out-of-range columns, early wins).

Quick Answer: This question evaluates a candidate's ability to design efficient data structures and algorithms for real-time game state management, including win detection, API design, time/space complexity analysis, and handling edge cases such as full or out-of-range columns.

Related Interview Questions

  • Determine Exact Layover Booking - Airbnb (medium)
  • Solve Linked-List and Iterator Problems - Airbnb
  • Implement Text Layout and Query Parsing - Airbnb (easy)
  • Parse Query Parameters Into a Map - Airbnb (medium)
  • Compute board-game score from regions - Airbnb (medium)
Airbnb logo
Airbnb
Jul 31, 2025, 12:00 AM
Software Engineer
Take-home Project
Coding & Algorithms
13
0

Implement a Connect Four game engine. Support a general m×n board (default 6× 7) and a win condition of k in a row (default 4). Provide an API: ConnectFour(m, n, k), move(column, player)->status where status returns 0 (no win), 1 or 2 (player wins), -1 (invalid move), and a separate method isDraw(). Discs fall to the lowest available cell in the chosen column. After each move, detect wins horizontally, vertically, and both diagonals. Design data structures to achieve O(

  1. or near O(
  2. time per move for win checking, and analyze time/space complexity. Extend the design to support reset() and optional undo() efficiently, and discuss how you would test edge cases (full columns, out-of-range columns, early wins).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Airbnb•More Software Engineer•Airbnb Software Engineer•Airbnb Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.