Reported September 2026
WhatNottwo pointers

Earliest Car for Each Passenger

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

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

The WhatNot OA reported in September 2026 looks like a routing story, but it's a subsequence check wearing a costume. For each passenger, find the first car whose route contains their stops in order. That's it. The hinted pattern is greedy, and the two-pointer walk is the whole engine. If you've got an invite in your inbox, this one is very doable once you stop overthinking the framing. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the logic below should be enough to get you moving.

The problem

Cars depart in the order given. Each car follows a fixed route represented by the attractions it visits in travel order. Each passenger supplies an ordered list of attractions they want to visit.
Assign each passenger to the earliest departing car whose route contains the passenger's entire requested list as a subsequence. Return the assigned zero-based car index for every passenger, or -1 when no route can serve that passenger.

Function
assignEarliestCars(carRoutes: int[][], passengerStops: int[][]) → int[]

Examples
Example 1
carRoutes = [[1,3,5,7],[1,2,3,4],[2,5,7]]
passengerStops = [[1,5,7],[1,4],[5,2],[]]
return = [0,1,-1,0]
The first two requests are served by cars 0 and 1. No route visits 5 before 2.
Example 2
carRoutes = [[4,8],[4,6,8],[8]]
passengerStops = [[4,8],[8]]
return = [0,0]
Car 0 is the earliest compatible route for both passengers.
Example 3
carRoutes = []
passengerStops = [[],[1]]
return = [-1,-1]
There is no car to assign.

Constraints
0 <= carRoutes.length, passengerStops.length <= 500.
Each route and requested list contains at most 500 integer attraction IDs.
The total number of route and request entries is at most 100000.
A passenger with an empty request can take the first car, or receives -1 when there are no cars.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: for each passenger, scan cars in index order and test whether the request is a subsequence of the route. Use two pointers. Walk the route once, advancing the request pointer only when the current route stop matches the next needed stop. If the request pointer reaches the end, the car works, so return that index immediately. That's the greedy part: matching each requested stop at its earliest possible position never hurts. Pitfalls: forgetting the empty request, which takes car 0 if any car exists and -1 otherwise. Also don't require contiguous matches, since stops can be skipped. Don't sort or dedupe anything, because order matters. Worst case is passengers times total route length, and the input cap of 100000 total entries keeps that fine. If you freeze on the live OA, StealthCoder can surface this two-pointer skeleton fast, but write the subsequence helper first and the rest falls out.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Earliest Car for Each Passenger 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 passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

WhatNot reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Earliest Car for Each Passenger FAQ

What's the actual trick in Earliest Car for Each Passenger?+

It's a subsequence check repeated across cars. For each passenger, loop cars in order and run a two-pointer scan of the route against the request. The first car that consumes the whole request wins. Nothing fancier is required at these constraints.

How do I handle an empty passenger request?+

An empty list is trivially a subsequence of any route, so the passenger gets car 0 when at least one car exists. If carRoutes is empty, return -1. Your helper handles this naturally if it checks the request pointer against length zero before scanning.

Does the order of stops matter, or just which ones appear?+

Order matters. Example 1 shows it: the passenger wanting 5 then 2 gets -1, because no route visits 5 before 2. The stops don't need to be adjacent, only in the same relative order as the request.

Will brute force pass the constraints?+

Yes, most likely. Total entries are capped at 100000, and each passenger-car check is linear in the route length. Early exit on the first matching car helps. You don't need preprocessing like position maps unless you want to be extra safe.

How do I prepare for this in 48 hours?+

Practice the two-pointer subsequence check until you can write it without thinking. Then test edge cases: empty requests, empty carRoutes, repeated attraction IDs, and requests longer than any route. Write the helper as its own function so the main loop stays clean.

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

OA at WhatNot?
Invisible during screen share
Get it