Reported September 2026
MakeMyTripheap priority queue

Parallel Workers with a Per-Phase Barrier

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

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

A MakeMyTrip OA reported in September 2026 hands you a scheduling problem that looks harder than it is. Tasks, workers, phases, barriers. The edge case that breaks a naive solution is the barrier reset: every phase starts all workers at the same global time, so you can't carry worker availability across phases. It's a simulation with a min-heap, run once per phase. If you blank on the setup during the live OA, StealthCoder is the invisible safety net that reads the problem and gives you a working solution. Know the shape first and you probably won't need it.

The problem

There are workers identical workers and a matrix phaseDurations, where row t contains the duration of every phase for task t. Within each phase, assign tasks in increasing task-index order to the worker that becomes available earliest; break equal-availability ties by smaller worker index. All workers begin the current phase at its global start time. No work for phase p + 1 may begin until every task finishes phase p. Return the cumulative completion time of each phase barrier.

Function
phaseBarrierCompletionTimes(workers: int, phaseDurations: int[][]) → long[]

Examples
Example 1
workers = 2
phaseDurations = [[3,2],[1,4],[2,1]]
return = [3,7]
Phase 0 completes at time 3. Every phase-1 task starts no earlier than time 3, and that phase completes at time 7.
Example 2
workers = 1
phaseDurations = [[2,3],[4,1]]
return = [6,10]
With one worker, each phase duration is the sum of its task durations.

Constraints
1 <= workers <= phaseDurations.length <= 100000
Every row has the same positive number of phases.
The total number of matrix entries is at most 200000.
Every duration is between 0 and 10^9, inclusive.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: treat each phase as an independent mini-schedule. Column p of the matrix holds the durations for phase p across all tasks. Start with a min-heap of size workers, all set to the current barrier time. For each task in index order, pop the earliest-free worker, add the duration, push it back. The phase ends at the max value in the heap, and that becomes the next barrier. The pitfall is carrying heap state from the previous phase, which lets fast workers start early and gives wrong answers. Another trap is overflow: durations reach 10^9 and sums go far past 32-bit, so use long. Zero durations are legal, so don't assume time always advances. Tie-breaking by worker index doesn't change the completion times, so a plain heap of times works. Cost is O(total entries times log workers). If the heap logic slips under pressure, StealthCoder can cover you during the live OA.

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 Parallel Workers with a Per-Phase Barrier 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 MakeMyTrip's OA.

MakeMyTrip 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.

Parallel Workers with a Per-Phase Barrier FAQ

What's the core trick in this MakeMyTrip OA problem?+

Run a separate greedy simulation per phase. Use a min-heap of worker free times, all reset to the previous barrier. Assign tasks in order to the earliest-free worker. The phase barrier is the largest finish time. Then repeat for the next column.

Do I need to track worker indices for the tie-break?+

No. The tie-break by smaller worker index affects which worker gets a task, not the multiset of free times. Completion times depend only on the times, so a heap of plain values gives the same barriers. Skip the index and keep the code simple.

What's the most common wrong answer?+

Carrying worker availability from one phase into the next. The statement says all workers begin each phase at the global start time, which is the previous barrier. If you don't reset the heap, you'll undercount and fail the sample with two workers.

Which data types matter here?+

Use 64-bit integers for all times. Durations go up to 10^9 and there can be 100000 tasks, so cumulative times overflow 32-bit easily. The return type is long[] for exactly that reason. Also remember zero durations are allowed.

How do I prepare for this in 48 hours?+

Write the per-phase heap simulation from scratch twice. Test it on both examples, then on workers equal to 1 and workers equal to the task count. Check zero durations and large values. Reading the matrix by column instead of row is the other thing to rehearse.

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

OA at MakeMyTrip?
Invisible during screen share
Get it