Compute triangle min path and dice stopping stats
Problem 1: Triangle Minimum Path Sum
Given a triangular array triangle with n rows, find the minimum path sum from the top to the bottom.
- You start at
triangle[0][0]. - From row
i, columnj, you may move to rowi+1at columnjorj+1. - Return the minimum possible sum along any valid top-to-bottom path.
Input: A list of lists, where row i has length i+1.
Output: An integer (or numeric) minimum path sum.
Constraints (typical): 1 <= n <= 2000, values may be negative/positive.
Problem 2: Two Dice Stopping Problem + Monte Carlo Simulation
There are two fair dice:
- Die A has faces
{1,2,3,4,5}(a 5-sided die). - Die B has faces
{1,2,3,4,5,6}(a 6-sided die).
The experiment proceeds in rounds. In each round, you roll both dice once.
- The process stops at the first round where at least one die shows
1. - In the stopping round:
- Die A wins if
A=1andB≠1. - Die B wins if
B=1andA≠1. - It is a tie if
A=1andB=1.
- Die A wins if
Answer the following:
- What is the probability that the 5-sided die (Die A) wins?
- What is the expected number of rounds until the process stops?
- Implement a Monte Carlo simulation to estimate (1) and (2), and discuss how many trials you would run to get a stable estimate.
AI interview prep
Core dilemma
Balancing the statistical rigor and precision of a Monte Carlo simulation against its computational cost and the practical constraints of execution time.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Compute triangle min path and dice stopping stats
Problem 1: Triangle Minimum Path Sum
Given a triangular array triangle with n rows, find the minimum path sum from the top to the bottom.
- You start at
triangle[0][0]. - From row
i, columnj, you may move to rowi+1at columnjorj+1. - Return the minimum possible sum along any valid top-to-bottom path.
Input: A list of lists, where row i has length i+1.
Output: An integer (or numeric) minimum path sum.
Constraints (typical): 1 <= n <= 2000, values may be negative/positive.
Problem 2: Two Dice Stopping Problem + Monte Carlo Simulation
There are two fair dice:
- Die A has faces
{1,2,3,4,5}(a 5-sided die). - Die B has faces
{1,2,3,4,5,6}(a 6-sided die).
The experiment proceeds in rounds. In each round, you roll both dice once.
- The process stops at the first round where at least one die shows
1. - In the stopping round:
- Die A wins if
A=1andB≠1. - Die B wins if
B=1andA≠1. - It is a tie if
A=1andB=1.
- Die A wins if
Answer the following:
- What is the probability that the 5-sided die (Die A) wins?
- What is the expected number of rounds until the process stops?
- Implement a Monte Carlo simulation to estimate (1) and (2), and discuss how many trials you would run to get a stable estimate.