FastPrepRandom Bingo Card Generator
Problems/Random Bingo Card Generator

Random Bingo Card Generator

Uber logoUber● MediumFULLTIMEONSITE INTERVIEW

Updated Dec 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported from an Uber onsite interview (full-time machine learning engineer, applied online) by a candidate with a PhD who was changing jobs. This was round 4 of 5, called Algorithm & Data.

The round asked for a random bingo card generator. The card rules it gave: 3 rows and 9 columns, 0 for an empty cell, five filled cells per row, at least one filled cell per column, and each column's values taken at random, with no repeats, from a band of ten values tied to that column. The candidate saw two parts to the work: a routine that chooses k items out of n, and keeping the row and column counts right at the same time. Their solution worked, but they doubted that every card had the same chance.

Part of the column range was lost in the report's formatting. Our reading is that column N, counted from 1 on the left, holds the numbers 10N to 10N + 9.

Everything else is our choice: the name generateBingoCard and the seed input, the random number generator, how a value is picked from a pool, drawing the rows first and redrawing the whole layout when a column is empty, drawing the numbers column by column from top to bottom, leaving each column unsorted, the order of the output, the limits and the examples. These fixed rules give one exact card per seed, so a test can check it. How evenly this method spreads the cards is discussed in the editorial and is not tested.

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

A bingo card is a grid with 3 rows and 9 columns. Each cell holds a number or 0, and 0 means the cell is empty. A valid card follows three rules:

  • Every row has exactly 5 numbers and 4 empty cells.
  • Every column has at least one number.
  • Column N, counting from 1 on the left, holds only numbers from 10N to 10N + 9, and no number appears twice in a column.

Write generateBingoCard(seed), which builds a random valid card. So that every correct program returns the same card for the same seed, make every random choice with the steps below.

Random numbers. Start with state = seed. A call next(bound) sets state = (state * 48271) mod 2147483647 and then returns state mod bound, a value from 0 to bound - 1. The product can need more than 32 bits, so compute it with 64-bit integers.

Picking from a pool. A pool is a list of values. To pick one, call i = next(size), where size is the number of values in the pool, and take pool[i]. Then copy the pool's last value into position i and remove the last position, so the pool has one value less.

Step 1, the layout. For each row from top to bottom, start a new pool [1, 2, 3, 4, 5, 6, 7, 8, 9] of column numbers and pick 5 of them. In that row, the 5 picked columns hold numbers and the other 4 cells stay empty. If after all three rows some column was picked by no row, throw the whole layout away and draw a new one, starting again from the top row. Keep using the same state; do not reset it. Repeat until every column has been picked at least once.

Step 2, the numbers. For each column N from 1 to 9, start a new pool [10N, 10N + 1, ..., 10N + 9] in increasing order. Go down the column from the top row to the bottom row, and for each cell that holds a number in the layout, pick one value from this pool and put it there. Empty cells use no pick and keep 0. Do not sort the numbers in a column.

Return the card as 3 arrays of 9 integers, top row first.

Function

generateBingoCard(seed: int) → int[][]

Examples

Example 1

seed = 1return = [[13,27,0,0,0,67,0,87,92],[12,26,36,0,0,62,72,0,0],[0,0,39,46,51,0,79,86,0]]

The first call sets state = 48271 and returns 48271 mod 9 = 4, so row 1 first takes pool[4] = 5. The first layout gives the rows the columns {2, 3, 5, 6, 7}, {2, 6, 7, 8, 9}, {2, 4, 6, 7, 8}. No row uses column 1, so this layout is thrown away. The second layout gives {1, 2, 6, 8, 9}, {1, 2, 3, 6, 7}, {3, 4, 5, 7, 8}, which covers all nine columns, so it is kept. Then column 1 fills rows 1 and 2 with two numbers from 10 to 19, column 2 does the same from 20 to 29, and so on.

Example 2

seed = 2return = [[11,21,33,0,53,0,0,0,94],[10,23,0,40,59,69,0,0,0],[0,0,39,0,58,63,73,83,0]]

The first layout, {1, 2, 3, 5, 9}, {1, 2, 4, 5, 6}, {3, 5, 6, 7, 8}, already covers every column, so no layout is thrown away. Each row has 5 numbers and 4 zeros, and every number in column N is between 10N and 10N + 9.

Example 3

seed = 2147483646return = [[18,23,0,45,0,67,79,0,0],[0,28,32,0,0,68,74,82,0],[15,0,0,0,52,66,73,0,90]]

The largest seed. The first product, 2147483646 * 48271, does not fit in 32 bits, so the multiplication must use a 64-bit integer.

Constraints

  • 1 <= seed <= 2147483646

More Uber Onsite Interview questions

  • Travelers per Consecutive City TripletONSITE INTERVIEW · Seen Dec 2026
  • Earliest Time All Users Are ConnectedPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Online Meeting Scheduler with Fixed RoomsONSITE INTERVIEW · Seen Oct 2026
  • Minimum Meeting Rooms with AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Serialize and Deserialize an N-Ary TreeONSITE INTERVIEW · Seen Oct 2026
  • Longest Continuous Subarray Within an Absolute-Difference LimitONSITE INTERVIEW · Seen Oct 2026
  • K Smallest Squares from a Sorted ArrayONSITE INTERVIEW · Seen Sep 2026
  • Grid Robot Route with Charging PrioritiesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Shortest Increasing Path to a TargetONSITE INTERVIEW · Seen Sep 2026
  • My Calendar IONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Tensor-Parallel MLP GradientsOpenAI · ONSITE INTERVIEWOpenAI interview questions
  • Transformer Attention and SwiGLU Forward PassGoogle · ONSITE INTERVIEWGoogle interview questions
  • Vanilla RNN Hidden StatesNVIDIA · PHONE SCREENNVIDIA interview questions
  • Scaled Dot-Product AttentionAmazon · PHONE SCREEN
  • Spiral MatrixAthenahealth · ONSITE INTERVIEW
  • Spiral MatrixNike, Inc. · ONSITE INTERVIEWNike, Inc. interview questions
  • Expected Value of Modified DiceJane Street · ONSITE INTERVIEWJane Street interview questions
  • Linear Layer Forward and Backward PassesMeta · ONSITE INTERVIEWMeta interview questions
  • Reservoir Sampling with Recorded DrawsStackAdapt · ONSITE INTERVIEWStackAdapt interview questions
  • Sliding-Window Averages as Reduced FractionsCoinbase · ONSITE INTERVIEWCoinbase interview questions
All Uber interview questionsSee Uber hiring insights
Saved
class Solution {
    public int[][] generateBingoCard(int seed) {
        // Write your code here.
    }
}
Checking account…