2daysbeforeinterview
Home1Companies2Problems3Experiences4Compensation5Assistant

Spaces

Saved work

Your prep

Notes6Bookmarks7Submissions

Community

Leaderboard8Send feedback
Contribute9
2daysbeforeinterview
2daysbeforeinterview

Straight from the interview room.

Browse

  • Companies
  • Problems
  • Experiences
  • Compensation
  • Leaderboard
  • Pricing

Contribute

  • Add a question
  • Share an experience
  • Report compensation
  • Committed Contributor
  • Send feedback

About

  • About 2daysbeforeinterview
  • Contact
  • Privacy
  • Terms
  • Refunds
  • Delivery

© 2026 2daysbeforeinterview

  • Instagram(opens in a new tab)
  • YouTube(opens in a new tab)
  • X (Twitter)(opens in a new tab)
  • help@2daysbeforeinterview.com
HomeCompaniesProblems
Keep holding ⌥Alt and press a number · ? for every shortcut
Back
DSA
2 reportslast asked …
Arcana

Shuttle Seat Capacity Check

A shuttle travels along a straight road in one direction only and never turns back. It has capacity passenger seats.

You're given a list of bookings, where bookings[i] = [riders_i, start_i, end_i]. Booking i is a group of riders_i people who board at start_i km from the depot and get off at end_i km.

Riders who get off at a point leave before new riders board there. So a seat freed at km x can be reused by someone boarding at km x.

Return true if every booking can be served without the number of people on board ever going over capacity. Otherwise return false.

Examples

Example 1

Input:  capacity = 4, bookings = [[2,1,5],[3,3,7]]
Output: false
Explanation: Between km 3 and km 5 both groups are on board, 2 + 3 = 5 riders, which exceeds 4 seats.

Example 2

Input:  capacity = 5, bookings = [[2,1,5],[3,3,7]]
Output: true
Explanation: The busiest stretch carries 5 riders, which fits exactly.

Example 3

Input:  capacity = 3, bookings = [[2,1,5],[3,5,7]]
Output: true
Explanation: The first group gets off at km 5 before the second group boards there, so there are never more than 3 riders on board.

Constraints

  • 1 <= bookings.length <= 1000
  • bookings[i].length == 3
  • 1 <= riders_i <= 100
  • 0 <= start_i < end_i <= 1000
  • 1 <= capacity <= 10^5

Domains

Backend
asked Sept 2026Report
Discussion
Related questions
Asked atArcana
My notes
Practice
EditorialLocked
Community solutions
Learning resources(1)
Arcana
Arcana