Car Pooling Capacity Check
Updated
Problem statement
A vehicle has integer capacity. Each row [passengers, start, end] in trips means that many passengers ride on the half-open interval [start, end).
Return true if every trip can be completed without the number of passengers aboard exceeding capacity; otherwise return false. Drop-offs at a location happen before pickups at that same location.
Function
canCarryAll(capacity: int, trips: int[][]) → booleanExamples
Example 1
capacity = 4trips = [[2,1,5],[3,3,7]]return = falseFive passengers would be aboard between locations 3 and 5.
Example 2
capacity = 5trips = [[2,1,5],[3,3,7]]return = trueThe maximum load is exactly five.
Constraints
1 <= capacity <= 10^90 <= trips.length <= 200000- Each trip has
1 <= passengers <= 10^9and0 <= start < end <= 10^9.
More Goldman Sachs Onsite Interview questions
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
- First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Dungeon HealthONSITE INTERVIEW · Seen Sep 2026
- Insert, Delete, And Get Random In Constant TimeONSITE INTERVIEW · Seen Sep 2026
- Least Recently Used CacheONSITE INTERVIEW · Seen Sep 2026
- Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Count Lamps Lighting Each PointAirbnb · OAAirbnb interview questions
- Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
- Minimum Cost K-Capable ModelsMicrosoft · OAMicrosoft interview questions
- Majority Labels over Audio IntervalsNooks · PHONE SCREEN
- Minimum Seats for One-Way Car PoolingSquadStack.ai · OA
- Choose ContainersIMC Trading · OAIMC Trading interview questions
- Find Number of Ways to Split ArrayGoogle · OAGoogle interview questions
- Find Network CallsAmazon · OA
- Call Auction Clearing Price and Order FillsHudson River Trading · PHONE SCREENHudson River Trading interview questions
- Calculating QuantilesIndeed · OAIndeed interview questions