Generate Pairwise-Distinct Bingo Boards
Updated
Problem statement
Make boardCount different 5 x 5 Bingo boards. Return each board as an array of 25 integers: read the rows from top to bottom, and each row from left to right.
- Row 0 of a board holds five different values from 1 through 15. Row 1 uses 16 through 30, and so on, up to row 4 with 61 through 75.
- Each cell you output uses exactly one random choice.
- No two boards may have the same first cell. That makes every board different from every other board.
Make the random choices with this fixed rule, so the same input always gives the same boards. Start with state = seed. Each call next(bound) first sets state = (1103515245 * state + 12345) mod 2^31, then returns state mod bound.
Keep one shared pool [1..15] for the first cells of all boards. For each board, pick its first cell with one call to next(poolSize). Then remove that value from the shared pool by swapping it with the last value in the pool. We call this swap-with-last removal.
Next, build a fresh, full pool for row 0, [1..15]. Remove the board's first-cell value from it with the same swap-with-last step, but without a random call. Then pick the other four cells of that row from this pool. For each later row, build a fresh pool of its 15 values and pick five cells, each with one call and the same swap-with-last removal. Output the values in the order you pick them.
Function
generateBingoBoards(boardCount: int, seed: int) → int[][]Examples
Example 1
boardCount = 1seed = 0return = [[1,3,2,5,14,24,17,26,25,18,33,39,36,41,45,49,57,46,59,52,72,61,71,74,68]]Each of the 25 cells uses one random choice from the seeded rule. Every row stays inside its own range, and no value repeats in a row. The result is one board, listed row by row.
Example 2
boardCount = 2seed = 0return = [[1,3,2,5,14,24,17,26,25,18,33,39,36,41,45,49,57,46,59,52,72,61,71,74,68],[9,4,15,10,6,26,18,17,30,25,32,45,43,42,31,60,54,57,59,56,63,64,67,66,70]]The first board is the same as in the first example. Its first cell is taken out of the shared pool, so the second board has to start with a different value. The two boards start with 1 and 9, so they are different.
Example 3
boardCount = 1seed = 7return = [[7,2,8,4,14,17,22,21,16,19,31,38,43,36,39,53,52,60,56,49,63,70,62,72,75]]A different seed gives a different series of random choices, so the board changes. Every row still stays inside its range, no value repeats in a row, and the result is the one board shown.
Constraints
1 <= boardCount <= 5.0 <= seed <= 2147483647.- The random-state update must give the exact mathematical result modulo
2^31, with no overflow errors.
More Google Phone Screen questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Sliding Window Attention over a KV CacheNVIDIA · PHONE SCREENNVIDIA interview questions
- Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
- Evenly Schedule Vehicle InspectionsAmazon · PHONE SCREEN
- Implement Cross-Entropy LossOpenAI · PHONE SCREENOpenAI interview questions
- Cumulative No-Intercept Regression BetasCitadel · PHONE SCREENCitadel interview questions
- Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
- Automation Pipeline, Part 2: Stage WorkersPlaid · PHONE SCREENPlaid interview questions
- K-Means Delivery ZonesDoorDash · PHONE SCREEN · ONSITE INTERVIEWDoorDash interview questions
- Token Bucket Request DecisionsDatadog · PHONE SCREENDatadog interview questions
- Gradient Descent for Linear RegressionMicrosoft · PHONE SCREENMicrosoft interview questions