FastPrepCar Pooling Capacity Check
Problems/Car Pooling Capacity Check

Car Pooling Capacity Check

Goldman Sachs logoGoldman Sachs● MediumFULLTIMEONSITE INTERVIEW

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Goldman Sachs superday report describes the exact vehicle-capacity sweep: each trip supplies passenger count, boarding point, and deboarding point, and the result says whether capacity is ever exceeded. The source omits the portable signature and bounds; this practice version is an approximately 98% match.

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[][]) → boolean

Examples

Example 1

capacity = 4trips = [[2,1,5],[3,3,7]]return = false

Five passengers would be aboard between locations 3 and 5.

Example 2

capacity = 5trips = [[2,1,5],[3,3,7]]return = true

The maximum load is exactly five.

Constraints

  • 1 <= capacity <= 10^9
  • 0 <= trips.length <= 200000
  • Each trip has 1 <= passengers <= 10^9 and 0 <= 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
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public boolean canCarryAll(int capacity, int[][] trips) {
      // write your code here
    }
}
Checking account…