← Agoda Interview Insights

Agoda·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Agoda data science or quant-adjacent interview with a probability question that also required a coding component. The problem was self-contained but had three parts, so the time pressure was real.

Questions Asked (1)

Q1

You have two dice: one with faces 1 through 5, the other with faces 1 through 6. You roll both repeatedly and stop as soon as either die shows a 1. What is the probability that the 5-sided die is the one that shows a 1 first? What is the expected number of rolls? Then implement a Monte Carlo simulation to verify.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Three parts in one question, which I didn't love.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, solve the probability analytically by conditioning on the first roll: compute the probability that the 5-sided die shows 1 while the 6-sided die does not, and divide by the total probability that at least one die shows 1. Then, for the expected number of rolls, recognize that the number of rolls until either die shows a 1 follows a geometric distribution with success probability equal to the probability of at least one 1 on a single roll. Finally, implement a Monte Carlo simulation to verify both results, ensuring the simulation runs enough trials for accuracy.

Pro tip: When explaining the expected number of rolls, explicitly state that the stopping condition is a Bernoulli trial with constant success probability, so the expectation is 1/p. This shows you understand the geometric distribution and can communicate it clearly.

1. Define the stopping condition and compute single-roll probabilities

Calculate the probability that at least one die shows a 1 on a single roll, and the probability that the 5-sided die shows 1 while the 6-sided die does not. These are the building blocks for both the probability and expected rolls.

2. Compute the probability that the 5-sided die wins

Use conditional probability: P(5-sided wins) = P(5-sided shows 1 and 6-sided does not) / P(at least one shows 1). Simplify the fraction to get the exact probability.

3. Compute the expected number of rolls

Since each roll is independent and the probability of stopping on any roll is constant, the number of rolls follows a geometric distribution. The expected number of rolls is 1 / P(at least one shows 1).

4. Implement Monte Carlo simulation

Write a simulation that repeatedly rolls both dice until a 1 appears, records which die showed 1 first and the number of rolls, then repeats for many trials. Compute the proportion of trials where the 5-sided die won and the average number of rolls.

5. Compare simulation results with analytical results

Check that the simulated probability and expected rolls are close to the theoretical values. Discuss any discrepancies and the effect of the number of trials on accuracy.

Key Points to Mention

  • Conditional probability formula: P(A|B) = P(A and B) / P(B)
  • Independence of dice rolls and the geometric distribution for the number of trials
  • Exact calculation: P(5-sided wins) = (1/5)*(5/6) / (1 - (4/5)*(5/6)) = (1/6) / (1/3) = 1/2
  • Expected rolls: 1 / (1/3) = 3
  • Monte Carlo simulation design: number of trials, random number generation, and convergence
  • Trade-offs: analytical solution is exact and fast; simulation is useful for verification and handling more complex scenarios

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.