MEDIUMasked at 1 company

Find the Minimum Amount of Time to Brew Potions

A medium-tier problem at 35% community acceptance, tagged with Array, Simulation, Prefix Sum. Reported in interviews at Goldman Sachs and 0 others.

Founder's read

You've got an array of potion brews with different completion times, and you need to find the minimum time to complete some subset of them. Goldman Sachs has asked this. It looks deceptively simple until you realize the greedy choice isn't obvious and the brute force simulation will time out. The trick lives in understanding how to order the potions and leverage prefix sums to avoid redundant calculations. If this problem catches you mid-OA and you blank on the pattern, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
1
Difficulty
MEDIUM
Acceptance
35%

Companies that ask "Find the Minimum Amount of Time to Brew Potions"

If this hits your live OA

Find the Minimum Amount of Time to Brew Potions 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 a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The core insight is that you can't just pick potions in arrival order. You need to simulate the brewing process while deciding which potions to include, but the naive approach recalculates overlaps. The pattern: sort by completion time, use a prefix sum or running total to track cumulative brew time, and test whether each potion fits your time budget. Many candidates start with a nested loop that revisits the same subsets. The real win is recognizing that once sorted, you can determine the optimal set with a single pass and O(n) math instead of O(n²) simulation. Simulation and prefix sum work together here, not in isolation. StealthCoder's value kicks in when you've drilled arrays but haven't seen this specific combination under timed pressure.

Pattern tags

The honest play

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

Find the Minimum Amount of Time to Brew Potions 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 a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find the Minimum Amount of Time to Brew Potions interview FAQ

How hard is this problem really?+

Medium difficulty with a 35% acceptance rate puts it near the ceiling of technical interviews. It's not conceptually complex, but the greedy+simulation blend trips candidates who over-optimize too early or underestimate the sorting step. You'll see it at places like Goldman Sachs.

What's the trick I'm missing?+

You're probably simulating every potion individually. The trick is to sort first, then use prefix sums to avoid recalculating the same brew time windows. Once sorted, the optimal subset becomes deterministic math, not trial and error.

When does the obvious approach fail?+

Trying potions in the order they arrive, or testing all 2^n subsets. Both miss the fact that sorting by completion time makes the problem monotonic. Once you sort, the answer becomes a one-pass calculation, not exponential.

Is this still asked at top companies?+

Yes. Goldman Sachs has asked it. It combines array basics with simulation logic in a way that feels real-world and exposes whether you optimize for clarity or just raw speed. That's attractive to quant shops.

How does this relate to prefix sum?+

Prefix sum lets you calculate cumulative brew time for any contiguous range in O(1) after O(n) preprocessing. This avoids recalculating the same time window every time you add a potion. It's the difference between O(n^2) and O(n).

Want the actual problem statement? View "Find the Minimum Amount of Time to Brew Potions" 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.