PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Agoda

Compute triangle min path and dice stopping stats

Last updated: Mar 29, 2026

Quick Overview

This composite question evaluates dynamic programming and algorithmic optimization via the triangle minimum path problem and probability, stopping-time analysis and Monte Carlo simulation through the two-dice experiment, testing competencies in DP, discrete probability, expected-value reasoning and empirical estimation.

  • nan
  • Agoda
  • Coding & Algorithms
  • Software Engineer

Compute triangle min path and dice stopping stats

Company: Agoda

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: nan

Interview Round: Technical Screen

You are given two independent interview questions. ## 1) Triangle minimum path sum (DP) 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`, column `j`, you may move to row `i+1` at column `j` or `j+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. --- ## 2) Two dice stopping problem + Monte Carlo 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=1` and `B≠1`. - Die B **wins** if `B=1` and `A≠1`. - It is a **tie** if `A=1` and `B=1`. Answer the following: 1. What is the probability that the **5-sided die (Die A) wins**? 2. What is the **expected number of rounds** until the process stops? 3. Implement a **Monte Carlo simulation** to estimate (1) and (2), and discuss how many trials you would run to get a stable estimate.

Quick Answer: This composite question evaluates dynamic programming and algorithmic optimization via the triangle minimum path problem and probability, stopping-time analysis and Monte Carlo simulation through the two-dice experiment, testing competencies in DP, discrete probability, expected-value reasoning and empirical estimation.

Related Interview Questions

  • Find two numbers that sum to a target - Agoda (nan)
Agoda logo
Agoda
Nov 14, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
8
0

You are given two independent interview questions.

1) Triangle minimum path sum (DP)

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 , column j , you may move to row i+1 at column j or j+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.

2) Two dice stopping problem + Monte Carlo

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=1 and B≠1 .
    • Die B wins if B=1 and A≠1 .
    • It is a tie if A=1 and B=1 .

Answer the following:

  1. What is the probability that the 5-sided die (Die A) wins ?
  2. What is the expected number of rounds until the process stops?
  3. Implement a Monte Carlo simulation to estimate (1) and (2), and discuss how many trials you would run to get a stable estimate.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Agoda•More Software Engineer•Agoda Software Engineer•Agoda Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.