FastPrepConnect Four Winner
Problems/Connect Four Winner

Connect Four Winner

Airbnb logoAirbnb● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names Connect Four. It leaves out the function signature, the board size, the rules for a valid move and the output wanted. We use the standard game.

Our version is about 75% the same as the reported question.

Play a standard game of Connect Four on a board with 6 rows and 7 columns.

The integer array moves gives the column of each move, in the order the moves are made. Player 1 moves first, and then the players take turns. Each disc falls to the lowest empty cell in its column.

Return the number of the first player who gets four of their discs in a row. The four discs must sit next to each other in a horizontal, vertical, or diagonal line. Return 0 if no one has won when the moves run out.

Every move is legal, and no move comes after a player has won.

Function

connectFourWinner(moves: int[]) → int

Examples

Example 1

moves = [3,2,3,2,3,2,3]return = 1

Player 1 drops every disc into column 3. Their fourth disc there, on the last move, completes a vertical line of four. So the answer is player one.

Example 2

moves = [0,0,1,1,2,2,3]return = 1

Player 1 drops one disc into each of columns 0 through 3, all on the bottom row. The other player stacks discs on top of the first three, which does not block the bottom row. The seventh move completes four in a row across the bottom, so the answer is player one.

Example 3

moves = [0,1,2,3]return = 0

The four moves drop one disc into each of the four leftmost columns, so every disc sits on the bottom row. The players alternate, so each player has only two discs, and they are not next to each other. No one has four in a row when the moves run out, so the answer is zero.

Constraints

  • 1 <= moves.length <= 42.
  • Every value in moves is an integer from 0 through 6.
  • Each move selects a column that is not full.
  • Player 1 moves first, then the players alternate.
  • The sequence stops at the first winning move or before any player wins.

More Airbnb Online Assessment questions

  • In-Memory File SystemOA · Seen Nov 2026
  • Task Management SystemOA · Seen Nov 2026
  • Recipe Management SystemOA · Seen Nov 2026
  • Progressive Banking SystemOA · Seen Nov 2026
  • Credit Accounts with Scheduled TransfersOA · Seen Oct 2026
  • Parcel Attribute Store with TTLOA · Seen Oct 2026
  • Parcel Event TrackingOA · Seen Oct 2026
  • Median Home Price by CityOA · Seen Sep 2026
  • Worker Management (Promotion Track), Part 4: Full-Shift Double PayOA · Seen Sep 2026
  • Worker Management (Promotion Track), Part 3: Promotions and SalaryOA · Seen Sep 2026

Similar questions at other companies

  • Rotate Matrix Regions Around the DiagonalsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Rotate Matrix Regions Around the DiagonalsHudson River Trading · OAHudson River Trading interview questions
  • Robot Navigation Around LasersRoblox · OARoblox interview questions
  • Leaves Remaining After Wind GustsOpenAI · OAOpenAI interview questions
  • Apply a Reversi MoveAmazon · OA
  • Flip, Invert, and Smooth a Binary ImageAbridge · OAAbridge interview questions
  • Count Straight-Line Word Occurrences in a GridOptiver · OAOptiver interview questions
  • First Completed Mingo LineEpic · OAEpic interview questions
  • Sort Every Matrix Border LayerCapital One · OACapital One interview questions
  • Rotate a Square Matrix ClockwiseVisa · OAVisa interview questions

Airbnb interview experiences

  • Airbnb OA · November 2026
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)
  • Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public int connectFourWinner(int[] moves) {
        // Write your code here.
    }
}
Checking account…