PIXELBANKv9.1.0
Menu

A vehicle has capacity seats. Given trips [numPassengers, from, to], return True if it's possible to pick up and drop off all passengers.

Input: first line = capacity, second = trips as passengers:from:to comma-separated.

Example:

Input:
4
2:1:5,3:3:7
Output:
False
Reasoning:
  • The vehicle has a capacity of 44 seats.
  • Two trips are scheduled: one with 22 passengers from location 11 to 55, and another with 33 passengers from location 33 to 77.
  • At location 33, the vehicle needs to pick up 33 more passengers when there are already 22 passengers on board, requiring a total of 2+3=52 + 3 = 5 seats.
  • Since 55 exceeds the vehicle's capacity of 44 seats, it's not possible to pick up and drop off all passengers.

Constraints:

  • 1 <= trips.length <= 1000
  • 1 <= capacity <= 10^5
  • 0 <= from < to <= 1000
🔒

Editor locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.