Reported September 2023
Amazonsimulation

Minimum Time Spent

Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Amazon OA. Under 2s to a working solution.
Founder's read

Amazon asked this in September 2023, and it's a trap that looks harder than it is. You need to find the earliest time to finish at least one comedy movie and one drama movie. The trick is that you're not optimizing a sequence of all movies. You're picking one comedy, one drama, and finding the best pairing. StealthCoder will spot the pattern if you freeze mid-approach.

The problem

Amazon Prime Video has movies in category 'comedy' or 'drama'. Determine the earliest time you can finish at least one movie from each category. The release schedule and duration of the movies are provided. You can start watching a movie at the time it is release or later. If you begin a movie at time t, it ends at t + duration. If a movie ends at time t + duration, the second movie can start at that time, t+ duration, or later. The movies can be watched in any order. Complete the function minimumTimeSpent which has the following parameters: int comedyReleaseTime[n]: release times int comedyDuration[n]: durations int dramaReleaseTime[m]: release times int dramaDuration[m]: durations

Reported by candidates. Source: FastPrep

Pattern and pitfall

This is a brute-force optimization problem disguised as a scheduling challenge. The key insight: you only need to watch two movies total, one from each category. For each comedy-drama pair, calculate the minimum time to finish both by considering which you watch first. The earliest finish time is the max of the two end times. Try all pairs and return the global minimum. The pattern is simple enumeration with a two-pointer or nested-loop strategy. Common pitfall: overthinking it as a greedy or dynamic-programming problem. StealthCoder will confirm the pairing logic when you're live if you blank on which order to watch them.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Minimum Time Spent cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Amazon's OA.

Amazon reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Time Spent FAQ

Do I have to watch movies in release order?+

No. You can start any movie at or after its release time. Watch comedy first, then drama, or vice versa. For each pair, compute both orders and take the minimum end time.

What's the trick Amazon is testing?+

Recognizing that you only need one movie from each category and that the answer is determined by trying all O(n*m) pairings, not by greedy selection or dynamic programming. Brute force is correct here.

How do I calculate the finish time for a pair?+

If you watch comedy first: start at max(now, comedy_release), end at that time plus comedy_duration. Then start drama at that end time, end at max(that, drama_release) plus drama_duration. Try both orders.

Is there a way to prune the search space?+

Sort both arrays by release time and duration. You can often skip movies with later release times and longer durations, but the safest approach under time pressure is a clean nested loop over all pairs.

How much time do I have to code this?+

This is a 15-20 minute problem if you recognize the pattern. The code is straightforward: loop through all comedy-drama pairs, compute minimum end time for both watch orders, track the global minimum. No complex data structures needed.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Amazon.

OA at Amazon?
Invisible during screen share
Get it