Car Pooling Problem Statement

You are tasked with driving a cab that moves in a straight line, only forward, and initially has 'C' empty seats available for passengers.

Given 'N' trips, each defined by three integers: 'Num', 'pickPoint', and 'dropPoint'. These represent 'Num' passengers waiting at 'pickPoint' who must be dropped at 'dropPoint'.

Determine whether you can successfully pick up and drop off all passengers for each trip.

Input:

The first line includes an integer ‘T’, representing the number of test cases.

For each test case:
The first line contains two integers, ‘C’ and ‘N’, the car’s capacity and the number of trips, respectively.
The following 'N' lines each contain three integers denoting the number of passengers, the pickup point, and the drop-off point.

Output:

For every test case, output “True” if the trips can be made successfully and “False” otherwise.
Output results for each test case on a new line.

Example:

Input:
T = 2
C, N = 4 3
Trip 1: 2 1 5
Trip 2: 3 3 7
Trip 3: 1 5 9

C, N = 4 2
Trip 1: 2 1 5
Trip 2: 3 2 4

Output:
False
True

Constraints:

  • 1 <= T <= 50
  • 1 <= C <= 10^5
  • 1 <= N <= 10^3
  • 0 <= passengers <= 100
  • 0 <= pickPoint, dropPoint <= 1000

Note: You do not need to print anything; simply implement the function and return the appropriate responses.

AnswerBot
4mo

The problem involves determining if a cab with a certain capacity can successfully pick up and drop off passengers at specified points for multiple trips.

  • Create a function that takes in the car's capa...read more

Help your peers!
Select
Add answer anonymously...

Amazon Software Developer interview questions & answers

A Software Developer was asked 1mo agoQ. Could you describe the process for designing a data structure that allows for al...read more
A Software Developer was asked 1mo agoQ. What is HTML?
A Software Developer was asked 1mo agoQ. What is MySQL?

Popular interview questions of Software Developer

A Software Developer was asked 1mo agoQ1. Could you describe the process for designing a data structure that allows for al...read more
A Software Developer was asked 1mo agoQ2. What is MySQL?
A Software Developer was asked 1mo agoQ3. What is Java?

Top HR questions asked in Amazon Software Developer

A Software Developer was asked 1mo agoQ1. Tell me about a time you had to get to the root cause of a problem
A Software Developer was asked 5mo agoQ2. What are the short-term and long-term goals for the team or organization?
A Software Developer was asked 5mo agoQ3. Why do you want to work at Amazon?
Amazon Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits