MEDIUMasked at 6 companies

Triangle

A medium-tier problem at 59% community acceptance, tagged with Array, Dynamic Programming. Reported in interviews at Agoda and 5 others.

Founder's read

Triangle is a medium-difficulty dynamic programming problem that shows up at Amazon, Apple, Salesforce, and other tier-1 companies. You're given a triangle of integers and need to find the minimum path sum from top to bottom, moving to adjacent elements one row at a time. The acceptance rate hovers around 59%, which means nearly half the candidates solving it live either time out on the recurrence or blow their space complexity. If you haven't drilled the bottom-up DP pattern, this is exactly where StealthCoder becomes your safety net during the actual assessment.

Companies asking
6
Difficulty
MEDIUM
Acceptance
59%

Companies that ask "Triangle"

If this hits your live OA

Triangle is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.

Get StealthCoder
What this means

The trap is thinking top-down recursion with memoization first. That works, but it's messier than it needs to be. The real pattern is bottom-up DP: start from the last row and work upward, keeping only a single array to store the minimum cost to reach each position in the current row. At each step, you update each element by adding the smaller of the two reachable positions from the row below. Space collapses from O(n^2) to O(n), and time is O(n^2) either way. Most candidates who fail either miss the space optimization or overcompartmentalize the problem into separate subroutines when a tight loop does the work. Array and Dynamic Programming are the core topics here. During a live OA, if the recurrence isn't clicking, StealthCoder pulls the bottom-up solution in seconds, invisible to the proctor.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Triangle recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Triangle interview FAQ

Is Triangle still asked at FAANG companies?+

Yes. Amazon, Apple, and Salesforce all report asking it. It's a classic DP filter used in phone screens and online assessments. The 59% acceptance rate suggests it's not a gimme, but it's a predictable signal for candidates who've practiced the pattern.

What's the trick to Triangle?+

Bottom-up DP instead of top-down. Start from the second-to-last row and work backward to the top, updating each element to the minimum cost to reach it. You only need one row of memory, not a full 2D table. That's where most optimizations fail.

Can I solve Triangle with top-down recursion?+

Yes, but it's slower to code and easier to mess up during the interview. Top-down with memoization works and passes, but bottom-up is cleaner and avoids the function-call overhead. If you're under time pressure in the OA, bottom-up is the safer bet.

How does Triangle relate to other DP problems?+

It's a variant of the minimum path sum family. The constraint that you can only move to adjacent elements in the next row differentiates it. If you've mastered the grid-based minimum path problem, Triangle is the next step up in reducing space complexity.

What size triangle should I expect in the assessment?+

The problem doesn't specify bounds in most OA versions, but the algorithm works for triangles of any size. Focus on the O(n^2) time and O(n) space solution. If your code times out, you've either misunderstood adjacency or used unnecessary recursion depth.

Want the actual problem statement? View "Triangle" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.