Beautiful Towers II
A medium-tier problem at 35% community acceptance, tagged with Array, Stack, Monotonic Stack. Reported in interviews at Salesforce and 0 others.
Beautiful Towers II hits hard if you haven't seen the monotonic stack pattern before. It's a medium-difficulty array problem that Salesforce has asked, and the acceptance rate sits around 35%, which means most people either nail it or walk away confused. The trick isn't sorting or greedy, it's building up two separate views of the array using a stack, then combining them. If you hit this live and don't recognize the pattern, you'll waste time on a brute-force that won't pass. StealthCoder is the safety net: it reads the problem, surfaces the optimal solution in seconds, invisible to the proctor.
Companies that ask "Beautiful Towers II"
Beautiful Towers II 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. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.
Get StealthCoderThe problem requires you to compute, for each position, some property that depends on elements to the left and right in a specific order. A naive O(n^2) or O(n^3) scan fails on large inputs. The insight is that a monotonic stack lets you precompute the 'influence' or 'contribution' of each element in one pass to the left, then one pass to the right, giving you O(n) total. The common mistake is trying to solve it greedily or sorting the input, which loses the positional structure you need. You build a stack, push elements, and pop based on a comparison rule, recording indices or values as you go. The second pass mirrors the first. StealthCoder handles the stack-building logic and the merge step, so if you blank on the exact pop condition or index bookkeeping during the assessment, you get a working reference instantly.
Pattern tags
You know the problem.
Make sure you actually pass it.
Beautiful Towers II 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. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Beautiful Towers II interview FAQ
Is Beautiful Towers II still asked at big companies?+
Yes, Salesforce has asked it. Medium-difficulty stack problems are common in assessment rounds because they filter for algorithmic pattern recognition without requiring advanced graph or DP knowledge. It's the kind of problem that shows up once you pass the easy tier.
What's the main trick to Beautiful Towers II?+
Monotonic stack. You make two passes: one to compute influence from the left, one from the right. Each pass uses a stack to avoid redundant comparisons. The trick is the pop condition and what you store (index vs. value). Get that wrong, and your array indexing breaks.
Why does the brute-force fail?+
A nested loop that checks all pairs or ranges is O(n^2) or worse, and it won't pass on large test cases. The monotonic stack reduces redundant comparisons to O(n) by reusing information from previous iterations, so you don't revisit the same elements.
How do I know when to use a monotonic stack?+
If the problem asks for the 'next greater/smaller element' or 'closest boundary' to the left or right of each position, monotonic stack is the go-to. Beautiful Towers II fits this pattern: you need properties that depend on element relationships across different sides of the array.
Is Beautiful Towers II harder than typical medium stack problems?+
The 35% acceptance rate suggests it's on the harder end of medium. The stack logic itself is standard, but the merge and final computation step require careful index handling. Most rejections come from off-by-one errors or misunderstanding what the stack stores.
Want the actual problem statement? View "Beautiful Towers II" on LeetCode →