FastPrepCount Card Duel Rounds
Problems/Count Card Duel Rounds

Count Card Duel Rounds

Airbnb logoAirbnb● EasyINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Airbnb online assessment. Two players duel with decks of creature cards. The higher card wins each round, a tie goes to the first player, and you count the rounds until one deck runs out.

The report gives the full rules, both examples and the card values from 1 to 10, but no deck size limit. Here, each deck holds 1 to 50 cards.

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

Given the decks playerDeckA and playerDeckB of two strategists in a fantasy card duel, return how many rounds the duel lasts.

The first player holds playerDeckA and the second player holds playerDeckB. Each card shows a mystical creature with a power value. Index 0 of each array is the top of that deck, and the last index is the bottom.

Each round follows these rules:

  • Each player reveals the top card of their deck.
  • If the power of the card from playerDeckA is greater than or equal to the power of the card from playerDeckB, the first player wins the round. Both cards go to the bottom of playerDeckA: the first player's own card, then the card from playerDeckB below it.
  • If the power of the card from playerDeckA is less than the power of the card from playerDeckB, the second player wins the round. Both cards go to the bottom of playerDeckB: the second player's own card, then the card from playerDeckA below it.

The duel ends when a player's deck is empty, because that player cannot draw another card.

Note: You don't need the most optimal solution. Any solution with time complexity no worse than O(playerDeckA.length^3) fits within the time limit.

Function

countDuelRounds(playerDeckA: int[], playerDeckB: int[]) → int

Examples

Example 1

playerDeckA = [5]playerDeckB = [2]return = 1

Breakdown of each round:

  • Round 1:
    • playerDeckA plays a 5, whereas playerDeckB presents a 2. The decks temporarily become empty.
    • Since 5 ≥ 2, 5 and 2 move to the bottom of playerDeckA.
      • Afterwards, playerDeckA = [5, 2] and playerDeckB = [].
    • With playerDeckB empty, the duel is over, resulting in a single round: 1.

Example 2

playerDeckA = [1,2]playerDeckB = [3,1]return = 6

Round 4 is a tie, so the first player wins it. After round 6, playerDeckA is empty, so the duel lasts 6 rounds.

RoundplayerDeckA cardplayerDeckB cardWinnerplayerDeckA afterplayerDeckB after
113Second player[2][1, 3, 1]
221First player[2, 1][3, 1]
323Second player[1][1, 3, 2]
411First player[1, 1][3, 2]
513Second player[1][2, 3, 1]
612Second player[][3, 1, 2, 1]

Constraints

  • 1 <= playerDeckA.length, playerDeckB.length <= 50
  • 1 <= playerDeckA[i], playerDeckB[i] <= 10
  • The duel is guaranteed to end.

More Airbnb Online Assessment questions

  • Count Lamps Lighting Each PointOA · Seen Nov 2026
  • Simulate Orchard Rot SpreadOA · Seen Nov 2026
  • Sort Adjacent PairsOA · Seen Nov 2026
  • 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

Similar questions at other companies

  • Chess TournamentJP Morgan Chase · OAJP Morgan Chase interview questions
  • Incident MonitorStripe · OAStripe interview questions
  • Realized PnL with Oldest Inventory FirstBelvedere Trading · OA
  • Buffet Day GainsUpstart · OAUpstart interview questions
  • Bank Requests with Delayed CashbackRamp · OARamp interview questions
  • Busy IntersectionIMC Trading · OAIMC Trading interview questions
  • Capital Gains Tax from TradesArcesium · OAArcesium interview questions
  • Ring Buffer OperationsAmazon · ONSITE INTERVIEW
  • Recent Hit CounterAmazon Web Services · ONSITE INTERVIEWAmazon Web Services interview questions
  • Implement a Queue Using an ArrayLondon Stock Exchange · PHONE SCREENLondon Stock Exchange 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 countDuelRounds(int[] playerDeckA, int[] playerDeckB) {
      // write your code here
    }
}
Checking account…