Minimum Bus Fleet Across Stations
Reported by candidates from Snowflake's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The mistake that sinks most first attempts at this Snowflake question is counting peak overlapping trips and calling it done. That ignores stations, and stations are the whole problem. Snowflake candidates reported Minimum Bus Fleet Across Stations in September 2026, and it looks like interval scheduling but isn't. A bus can only continue from where it ended, so a trip arriving at B only helps a trip departing from B. If you've got an OA coming in a day or two, learn the per-station matching idea below. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the idea is short enough to hold in your head.
The problem
Each trip in trips is [origin, destination, departure, arrival], where the two times are decimal nonnegative integers. A bus can operate a trip when it is initially assigned to that trip's origin or when it completed an earlier trip at the same origin at or before the new departure time. A bus cannot reposition between different stations without a listed trip. Return the minimum number of buses required to operate every trip. Function minimumBuses(trips: String[][]) → int Examples Example 1 trips = [["A","B","0","5"],["B","C","5","9"],["A","C","2","6"]] return = 2 One bus continues from the first trip to the second; another starts the overlapping A-to-C trip. Example 2 trips = [["A","B","1","4"],["C","A","0","1"],["B","C","4","8"]] return = 1 A single bus can operate C-to-A, A-to-B, then B-to-C. Example 3 trips = [["A","B","0","10"],["A","C","1","2"],["B","A","10","12"]] return = 2 The two early departures from A overlap. Constraints 1 <= trips.length <= 10^5. 0 <= departure < arrival <= 10^9. Station names are non-empty ASCII strings.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Think of each trip as a node. Trip i can feed trip j if i's destination equals j's origin and i's arrival is at or before j's departure. The minimum buses equal total trips minus the maximum number of such links, since every link saves one bus. Each trip has one arrival role and one departure role, so stations are independent. Per station, collect arrival times and departure times as integers, sort both, then walk departures in ascending order and match each with the earliest unused arrival that's at or before it. Count matches, sum across stations, return n minus that. Pitfalls: comparing times as strings, using strict less-than when equal times are allowed, and ignoring station identity. Complexity is O(n log n), fine for 10^5 trips. If the logic slips under pressure, StealthCoder can surface this matching approach live while you finish the code.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Minimum Bus Fleet Across Stations 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Snowflake's OA.
Snowflake reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Bus Fleet Across Stations FAQ
How hard is Minimum Bus Fleet Across Stations really?+
Medium to hard on paper, easy once you see it. The hard part is realizing it's a path cover that splits into independent per-station greedy matchings. The code afterward is a hash map, two sorted lists, and a two-pointer pass.
What's the trick for this Snowflake OA question?+
Answer equals trips minus maximum links. A link joins a trip arriving at station S to a later-or-equal departure from S. Group by station, sort arrivals and departures, and greedily match. Stations never interact, so matches simply add up.
Why doesn't a simple max-overlap sweep work?+
Overlap counting assumes any bus can serve any trip. Here buses can't reposition without a listed trip, so a free bus at the wrong station is useless. Example 3 shows it: the trips from A overlap, forcing two buses despite other idle capacity elsewhere.
Do equal arrival and departure times count as a connection?+
Yes. The statement says a bus can take a trip if it completed an earlier one at or before the new departure. So arrival 5 and departure 5 at the same station match. Use less-than-or-equal, and parse the times as integers, not strings.
How do I prepare for this in 48 hours?+
Write the solution once from scratch: parse times, build per-station arrival and departure lists, sort, two-pointer match, return n minus matches. Then test it against the three examples, especially the equal-time case. That covers the full pattern without needing a broader review.