PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates proficiency in dynamic programming and algorithmic problem-solving within the Coding & Algorithms domain, focusing on handling triangular data structures, index transitions, and numeric aggregation.

  • medium
  • TikTok
  • Coding & Algorithms
  • Machine Learning Engineer

Compute minimum path sum in a triangle

Company: TikTok

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given a triangle of integers represented as a list of rows, find the **minimum path sum** from the top to the bottom. - From row `r` and index `c`, you may move to row `r+1` at index `c` **or** `c+1`. - Return the minimum possible sum along any valid path. ### Input - `triangle`: a list of lists of integers, where `triangle[i]` has length `i+1`. ### Output - An integer: the minimum path sum. ### Constraints (typical) - `1 <= number of rows <= 200` - Values can be negative or positive and fit in 32-bit signed integer. ### Example Triangle: - `[2]` - `[3, 4]` - `[6, 5, 7]` - `[4, 1, 8, 3]` Minimum path sum is `2 + 3 + 5 + 1 = 11`.

Quick Answer: This question evaluates proficiency in dynamic programming and algorithmic problem-solving within the Coding & Algorithms domain, focusing on handling triangular data structures, index transitions, and numeric aggregation.

Return the minimum top-to-bottom path sum in a triangle.

Constraints

  • Row i has length i+1

Examples

Input: ([[2], [3, 4], [6, 5, 7], [4, 1, 8, 3]],)

Expected Output: 11

Explanation: Prompt example.

Input: ([[-10]],)

Expected Output: -10

Explanation: Single negative value.

Input: ([],)

Expected Output: 0

Explanation: Empty triangle.

Input: ([[1], [2, 3]],)

Expected Output: 3

Explanation: Two rows.

Hints

  1. Compute minimum suffix path sums from the bottom row upward.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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
  • AI Coding 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.

Related Coding Questions

  • Parse a nested list from a string - TikTok (medium)
  • Implement stacks, streaming median, and upward path sum - TikTok (easy)
  • Implement stack variants and path-sum check - TikTok (medium)
  • Find the longest palindromic substring - TikTok (easy)
  • Maximize sum with no adjacent elements - TikTok (medium)