Reported September 2026
Amazondynamic programming

Maximum Profit in Job Scheduling

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

The Amazon OA reported in September 2026 hands you Maximum Profit in Job Scheduling, and the trap is a single boundary: a job that starts exactly when another ends is allowed. Get that comparison wrong and your answer is off on the very first example. It's a sort plus dynamic programming plus binary search problem, and with 50000 jobs an O(n^2) approach will die. If you blank on the recurrence in the live assessment, StealthCoder runs invisibly on your desktop as a safety net and gives you the solution in real time. Here's the pattern and the pitfalls.

The problem

You are given equal-length arrays startTime, endTime, and profit. Job i runs on the half-open interval from its start time to its end time and earns its profit.
Select non-overlapping jobs to maximize total profit. A job that starts exactly when another ends does not overlap.

Function
jobScheduling(startTime: int[], endTime: int[], profit: int[]) → int

Examples
Example 1
startTime = [1,2,3,3]
endTime = [3,4,5,6]
profit = [50,10,40,70]
return = 120
Choose jobs [1,3) and [3,6) for profit 120.
Example 2
startTime = [1,2,3,4,6]
endTime = [3,5,10,6,9]
profit = [20,20,100,70,60]
return = 150
Jobs [1,3), [4,6), and [6,9) earn 150.
Example 3
startTime = [1,1,1]
endTime = [2,3,4]
profit = [5,6,4]
return = 6
All jobs overlap, so choose the highest-profit one.

Constraints
1 ≤ startTime.length = endTime.length = profit.length ≤ 50000.
0 &le; startTime[i] < endTime[i] &le; 10^9.
1 &le; profit[i] &le; 10000.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Sort jobs by end time. Let dp[i] be the best profit using the first i jobs in that order. For job i, you either skip it, so dp[i-1], or take it, so profit[i] plus dp[j], where j is the count of jobs whose end time is less than or equal to start[i]. Find j with binary search on the sorted end times, using upper bound so that end == start counts as compatible. That's the edge case. Using strict less-than silently drops valid pairs like [1,3) and [3,6) and gives 70 instead of 120. Don't try to index by time, since times go up to 10^9. Total cost is O(n log n). Sums fit in a 32-bit int here, but a long is harmless. If the recurrence slips away mid-assessment, StealthCoder is your hedge.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Maximum Profit in Job Scheduling 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as maximum profit in job scheduling. If you have time before the OA, drill that.

⏵ The honest play

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

Amazon reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximum Profit in Job Scheduling FAQ

What's the trick in Maximum Profit in Job Scheduling?+

Sort by end time, then dp[i] = max(dp[i-1], profit[i] + dp[j]) where j is the number of jobs ending at or before job i's start. Binary search finds j fast. The whole thing is a weighted interval scheduling problem, and greedy by profit or by end time alone fails.

Why does the boundary case matter so much?+

The problem says a job starting exactly when another ends doesn't overlap. In example 1, [1,3) and [3,6) must combine for 120. If your binary search uses strict less-than on end time, you skip that pairing and return a smaller number. Use end <= start as compatible.

Can I solve this with plain O(n^2) DP?+

Not safely. With up to 50000 jobs, a double loop means billions of operations in the worst case. Sorting plus binary search brings it to O(n log n), which is what the constraints are pushing you toward. Treat the O(n^2) version as a stepping stone only.

Is this pattern still asked at Amazon?+

It was reported in the Amazon OA in September 2026, so yes, it's live. Interval DP with binary search shows up often enough that recognizing weighted interval scheduling on sight is worth it. Expect small variations in input format rather than a new technique.

How do I prepare in 48 hours?+

Write this solution once from scratch: sort by end, build an end-time array, binary search with upper bound, fill dp. Then test example 1 and example 3 by hand. Also remember the recurrence in words: skip it or take it plus the best compatible prefix. That's the whole problem.

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