Reported September 2026
SquadStack.aisorting

Minimum Seats for One-Way Car Pooling

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

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

SquadStack.ai reported this one in September 2026, and the input size is the whole story. Up to 10^5 trips, with points as large as 10^9, means you can't walk every point on the route or check every pair of trips for overlap. This is Car Pooling in a new coat: find the peak number of passengers in the car at once. If you've got the OA in a day or two, learn the event sweep below. And if your mind goes blank mid-assessment, StealthCoder runs invisibly on your desktop as a safety net and hands you the approach.

The problem

A car travels in one direction along a route. You are given an array stops, where each row is [passengers, from, to].
passengers people enter the car at point from.
The same people leave the car at point to.
At a point where both events occur, passengers leaving the car get out before new passengers enter.
Return the minimum number of seats the car needs so that every trip can be completed. This is the maximum number of passengers simultaneously in the car.

Function
minimumSeats(stops: int[][]) → int

Examples
Example 1
stops = [[2,1,5],[3,3,7]]
return = 5
Between points 3 and 5, both groups are in the car, so 2 + 3 = 5 seats are required.
Example 2
stops = [[2,1,5],[3,5,7]]
return = 3
At point 5, the first two passengers leave before the next three enter. The groups never overlap, so only 3 seats are needed.
Example 3
stops = [[4,0,10],[2,2,6],[5,6,8],[1,8,9]]
return = 9
At point 6, two passengers leave before five enter. The occupancy becomes 4 + 5 = 9, the maximum along the route.

Constraints
1 <= stops.length <= 10^5.
Every row in stops has exactly three integers.
1 <= passengers <= 10^4.
0 <= from < to <= 10^9.
The sum of all passengers values is at most 10^9.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is a sweep over events. Turn each trip into two events: +passengers at from, and -passengers at to. Sort events by position. At the same position, process the drops before the pickups, because the problem says people leave before new ones enter. Walk through the sorted list, keep a running total, and track the maximum. That's O(n log n) and handles 10^9 coordinates because you only touch real event points. The common pitfall is tie ordering. If you sort only by position and let a pickup come first, Example 2 returns 5 instead of 3. A sort key of (position, delta) fixes it, since negative deltas come first. Another miss is allocating an array of size 10^9 for a difference array. A sorted map or a sorted list of events avoids that. If you blank on the tie rule live, StealthCoder is the hedge that keeps you from shipping the wrong ordering.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Minimum Seats for One-Way Car Pooling 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as car pooling. If you have time before the OA, drill that.

⏵ The honest play

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

SquadStack.ai reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Seats for One-Way Car Pooling FAQ

What's the trick to Minimum Seats for One-Way Car Pooling?+

Convert each trip into a +passengers event at from and a -passengers event at to. Sort the events, apply a running sum, and return the highest value the sum reaches. It's a sweep line, and it avoids checking every pair of overlapping trips.

Why can't I just use an array indexed by point?+

Points go up to 10^9, so a difference array that size blows memory and time. With at most 10^5 trips, you only have 2*10^5 meaningful points. Sort those events or use a sorted map and skip the empty stretches entirely.

How do I handle two events at the same point?+

Drops go first. The problem states passengers leaving get out before new ones enter. Sort by (position, delta) so the negative delta comes before the positive one. Example 2 proves it: at point 5, the answer stays 3, not 5.

What's the time complexity I should aim for?+

O(n log n), dominated by sorting 2n events. The sweep itself is linear. With n up to 10^5, that's comfortably fast. Anything quadratic, like comparing every trip against every other, will time out on large inputs.

How do I prepare for this in 48 hours?+

Write the sweep from memory twice: build events, sort with the drop-first tiebreak, accumulate, track the max. Then test on the three examples, especially Example 2 for the tie case. Also learn the heap-based alternative, but the sweep is the cleaner answer.

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

OA at SquadStack.ai?
Invisible during screen share
Get it