As reported: Expedia Senior Software Engineer technical screen, 60 minutes with an engineer (2026), second problem: an array of stock trade logs
[buy_time, sell_time, profit]. Choose trades that do not overlap to maximise the total profit; a trade whosesell_timeequals another'sbuy_timedoes not overlap it. Example: trades0: [1,3,20],1: [2,4,10],2: [3,5,10]— trades 0 and 2 are compatible, 0 and 1 overlap. Sorting by the wrong field led to one of three tests failing; the complexity question was answered.
The runner uses the same problem in LeetCode's shape: trade i is startTime[i] (buy), endTime[i] (sell) and profit[i]. Return the maximum total profit of a set of trades with no overlapping time ranges; a trade may start at the exact time another ends.
This is LeetCode 1235 — Maximum Profit in Job Scheduling.
Example
startTime = [1,2,3], endTime = [3,4,5], profit = [20,10,10] -> 30 (trades 0 and 2)
startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70] -> 120
Constraints: 1 ≤ n ≤ 5·10^4; 1 ≤ startTime[i] < endTime[i] ≤ 10^9; 1 ≤ profit[i] ≤ 10^4.
Code runner format: one JSON value per line: startTime, endTime, then profit. Implement jobScheduling(startTime, endTime, profit); the harness prints the maximum profit.