InterviewLegend

Merge Intervals, Trade Scheduling & Ship Capacity

Alex Chen40 min readGuide updated
In this lesson
  • Pin down a vague interval prompt with a few questions before you write code
  • Merge overlapping intervals by sorting once and holding one open interval
  • Pick non-overlapping trades for maximum profit with a sorted DP and binary search
  • Attend the most events with a min-heap of end days
  • Find the least ship capacity by binary searching the answer

No live problem comes up more often in Expedia coding rounds than merge intervals. Five candidates have described it since 2023, and the two newest were both in 2026. A Senior SWE technical screen had it in March, and an SDE III (GenAI/ML) elimination round in India opened with it in April.

The other three problems here turned up in the same rounds. That March senior screen followed merge intervals with something like picking non-overlapping stock trades for the most profit. A March 2026 SDE II loop asked for the most events you can attend in round one, then capacity to ship packages within D days in round two. Ship capacity has no intervals in it at all. It's here because it has three reports from 2024 to 2026, and twice it came up in the same candidate's Expedia loops as an interval problem.

The Expedia angle
Expedia runs your code against test cases, and some interviewers review it like a pull request. A merge that works but reads badly can still cost you. Name things for what they hold, keep the loop short, and run your own edge cases before the interviewer does.

Clarify the input before you code

In a December 2023 SDE II round in India, the interviewer opened with a very vague prompt. Only after a few clarifying questions did it turn out to be merge intervals. The rest of the 45 minutes was graded as if the code were headed to production. Readability and extensibility came up, and even the function names were questioned in review.

The 2026 reports read cleaner, but the habit still pays. One March 2026 write-up describes an expected output that departs from the textbook version: when nothing overlaps, return one interval covering them all. That's a good reason to agree on the output with one small example before you type. These are the questions worth asking for any interval prompt:

  • Is the input sorted by start, or do I sort it?
  • Do ranges that only touch, like [1, 4] and [4, 5], count as overlapping?
  • What comes back for an empty list or a single range?
  • Should I return a new list, or is changing the input in place fine?

The touching question changes the code by one character, <= or <. In booking data a checkout and a same-day check-in share a date without clashing, so a calendar of booked nights may want them kept apart. Ask, then say which one you picked out loud.

Three moves cover this lesson. Sort the intervals and sweep them once, holding only the latest merged one. For weighted picks, sort by end time and binary-search the last compatible choice. When the question asks for the smallest value that works, binary-search the value itself and test each guess with a greedy pass.

Asked at Expedia

Each problem below runs against tests in the editor, the way Expedia's HackerRank rounds do. Merge intervals goes first because it's asked most. The other three follow the rounds they came from.

Merge overlapping intervals

Five firsthand reports, from March 2023 to April 2026. In the March 2026 Senior SWE screen, intervals came as [start_time, end_time] pairs and the ask was a new array of merged ones. That candidate finished quickly and then explained the time complexity. In April 2026 an SDE III candidate tried comparing neighbours pairwise, lost track of the merged state partway through and only partly converged. An October 2025 SDE III round in India had it too. So did a March 2023 SDE III round in Gurugram, along with a variation the candidate didn't spell out.

1

Merge Overlapping Intervals

MediumSignature problem
Problem
You're given a list of time intervals, each a pair [start, end] with start <= end. The list is in no particular order.

Merge every group of overlapping intervals into one interval that covers the whole group, and return the merged intervals sorted by start. Two intervals that only touch, such as [1, 4] and [4, 5], count as overlapping. An empty list returns an empty list.
Inputintervals = [[1,3],[2,6],[8,10],[15,18]]Output[[1,6],[8,10],[15,18]]

[1,3] and [2,6] overlap, so they become [1,6]. The other two stand alone.

How this uses the pattern

Sort by start. Keep the merged list and compare each interval only with its last entry: stretch that entry when they overlap, otherwise append a new one.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Merge Overlapping Intervals

Loading...
Click "Run" to execute your code
The Expedia angle
The April 2026 SDE III candidate compared each interval with its neighbour and found the merged state drifting halfway through. After sorting, only the last merged interval matters, so compare against that and nothing else. The 2023 round in India judged the code as if it were shipping, down to the function names. Call it merge_intervals, name the loop variables start and end, and return a new list so the caller's input stays untouched.
Take it further
Insert one new booking into a list that's already merged and sorted. Sorting again would cost O(n log n) for one insert. Walk the list once instead. Copy every interval that ends before the new one starts, absorb every interval that overlaps it by widening the new one, then copy the rest. That's O(n), and it's worked below.

Non-overlapping trades for maximum profit

The March 2026 Senior SWE screen followed merge intervals with this one. The input was something like a log of stock trades, each [buy_time, sell_time, profit], and you choose trades that don't overlap to get the most total profit. Selling and buying at the same time doesn't count as overlap, since you can sell on day 3 and buy again on day 3. The candidate sorted on the wrong field, hit a binary search bug and failed one of three tests, yet still got the next round. A December 2023 SDE II assessment in India had the same problem as plain job scheduling.

2

Non-Overlapping Trades for Maximum Profit

HardCommonly asked
Problem
You're given a list of trades. Each trade is [buy_time, sell_time, profit] with buy_time < sell_time and a positive profit.

You can hold one trade at a time, so two chosen trades must not overlap. A trade that sells at time t doesn't overlap one that buys at time t.

Return the largest total profit you can make from a set of non-overlapping trades. An empty list returns 0.
Inputtrades = [[1,3,20],[2,4,10],[3,5,10]]Output30

The first and third trades share time 3, which is allowed, for 20 + 10. The first and second overlap.

How this uses the pattern

Sort the trades by sell time. Let best[i] be the most profit from the first i trades. For each trade, either skip it or add its profit to best[k], where k counts the earlier trades that sell at or before its buy time.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Non-Overlapping Trades for Maximum Profit

Loading...
Click "Run" to execute your code
The Expedia angle
The March 2026 candidate thought the problem got harder because they sorted on the wrong field. Sort by sell time, so the trades that fit before any given trade form a prefix you can binary-search. Same-time sell and buy is allowed, so use bisect_right on the sell times to keep those chains. That candidate failed a test on a binary search bug and still advanced, so say the complexity even if one test stays red.
Take it further
Return the trades you picked as well as the total. Record whether each step took its trade, then go back from the end. A taken trade joins the list and you jump to the prefix it built on. Otherwise move back one entry. It's worked below.

Maximum number of events you can attend

Round one of a March 2026 SDE II loop was this problem, and it's the only report so far. Each event runs over a range of days, you can go to it on any single day in that range, and you attend at most one event a day. You want as many events as possible. It resembles the trades problem, though with every event worth the same, a greedy rule is enough and no table is needed.

3

Maximum Number of Events You Can Attend

MediumCommonly asked
Problem
You're given a list of events, each [start_day, end_day] with both days included. You can attend an event on any one day from its start day to its end day.

You can attend only one event per day. Return the largest number of events you can attend.
Inputevents = [[1,2],[2,3],[3,4]]Output3

Attend the first on day 1, the second on day 2 and the third on day 3.

How this uses the pattern

Walk the days in order. Push the end day of every event that has started onto a min-heap, drop the ones that have already ended, and attend the one that ends soonest.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Maximum Number of Events You Can Attend

Loading...
Click "Run" to execute your code
The Expedia angle
The greedy rule is short: on each day, attend the open event that ends soonest, since it has the fewest days left to fit. Say that rule and why before you code, since the obvious next question is why it's safe. Two details decide whether it passes. A min-heap of end days makes the soonest-ending event cheap to find. And jumping straight to the next start day when the heap is empty keeps long gaps from costing a loop step per day.
Take it further
Each event now has a value, attending one takes its whole range, and you can attend at most k. The greedy rule no longer works, because a valuable event can be worth losing two cheap ones. Sort by end day and add a count to the trades table, so best[j][i] is the most value using j events from the first i. Taking event i adds its value to best[j - 1][k], where k counts the events that end before it starts, found by binary search on end days.

Capacity to ship packages within D days

Three firsthand reports, from February 2024 to March 2026. The newest opened round two of the March 2026 SDE II loop. An October 2025 SDE III round in India had it too, and the candidate solved it. The February 2024 SDE III version in Gurugram told it as a conveyor belt of package weights to ship within B days, loading in order each day. Same problem, different letters.

4

Capacity to Ship Packages Within D Days

MediumCommonly asked
Problem
Packages wait on a conveyor belt, and weights[i] is the weight of the i-th one. Each day you load the ship with packages in belt order, without going over the ship's weight capacity, and ship them.

Return the smallest capacity that ships every package within days days. Packages can't be reordered or split.
Inputweights = [1,2,3,4,5,6,7,8,9,10]days = 5Output15

With capacity 15 the days are [1,2,3,4,5], [6,7], [8], [9], [10]. Capacity 14 needs six days.

How this uses the pattern

The capacity is somewhere between the heaviest package and the total weight. Binary search that range, and for each guess count the days a greedy load needs.

Write it here, or go full screen with the problem, hints and solution beside the editor.

Capacity to Ship Packages Within D Days

Loading...
Click "Run" to execute your code
The Expedia angle
The answer here is a number, and whether a number works is easy to check. Given a capacity, fill each day until the next package won't fit, and count the days. More capacity never needs more days, so the check flips from too few to enough exactly once. Binary search the capacity between the heaviest package and the total. Say those two bounds and why out loud, since the bounds are where your reasoning shows.
Take it further
Return the day-by-day loads as well as the capacity. Once the search settles, run the same greedy fill one more time at that capacity and record each day's packages. The greedy check can also finish in fewer than days days, which is fine, since an empty day at the end costs nothing. Say that so the interviewer knows you saw it.

Common questions

Is merge intervals still asked at Expedia?

Yes. It's the most repeated live problem, with five firsthand reports from 2023 to April 2026. The two 2026 reports came from a Senior SWE technical screen and an SDE III elimination round in India.

Are Expedia interview questions on LeetCode?

All four problems here have LeetCode equivalents: Merge Intervals, Maximum Profit in Job Scheduling, Maximum Number of Events That Can Be Attended and Capacity To Ship Packages Within D Days. Expedia's wording can differ, like trades instead of jobs, so learn the shape rather than the text.

What do Expedia SDE 2 coding interview questions look like?

One March 2026 SDE II loop gives a feel for it. Round one was the events problem. Round two had ship capacity and a stock-trading DP with at most k transactions. Expect mediums with a hard mixed in, run against test cases in HackerRank.

How should I practice these four?

Code each from a blank file on a timer, starting with the clarifying questions out loud. Expedia rounds often put two problems in one hour, so aim to finish merge intervals in about 15 minutes. That leaves time for a harder second problem.

Key Takeaways

  • ✓Merge intervals is the most repeated Expedia live problem. Sort once and compare only with the last merged interval.
  • ✓Ask about sorting, touching endpoints and empty input first. One reported round started with a very vague prompt.
  • ✓For weighted trades, sort by sell time and use bisect_right, since a sell and a buy can share a time.
  • ✓Ship capacity is binary search on the answer, from the heaviest package to the total weight.
Expedia interview guide

Know what Expedia asks before you walk in.

39 coding · 6 system design · 23 behavioral questions

Get Premium$49 a year · Instant access
Or start freeNo card.

Get their questions first.

The Expedia Online Assessment (HackerRank)Had your Expedia interview?How we research

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.