Economical Trip
Updated
Problem statement
A company has n teams. The integer array teamSizes gives the number of members in each team, and carSeats[i] gives the number of seats in the one car owned by team i.
A team participates in the company trip only when it has more than two members. If a team does not participate, neither its members nor its car are used. Members of participating teams may share cars across team boundaries.
Return the minimum number of participating teams' cars needed to carry every participating member. Return -1 if no team participates or if the available participating cars cannot carry everyone.
Function
minimumCars(n: int, teamSizes: int[], carSeats: int[]) → intExamples
Example 1
n = 3teamSizes = [4,5,7]carSeats = [7,6,7]return = 3All three teams participate, so 16 members need seats. The two largest cars have only 14 seats together, so all three cars are required.
Example 2
n = 4teamSizes = [4,2,3,5]carSeats = [6,9,5,7]return = 2The second team does not participate, so its 9-seat car is unavailable. The remaining teams have 12 members, and the 7- and 6-seat cars can carry them using two cars.
Example 3
n = 3teamSizes = [2,1,2]carSeats = [5,4,6]return = -1No team has more than two members, so nobody participates and the required result is -1.
Constraints
1 <= n <= 10^5.teamSizes.length == n.carSeats.length == n.1 <= teamSizes[i] <= 10^9.1 <= carSeats[i] <= 10^9.
More Accenture interview questions
- Nearest Composite NumberOA · Seen Sep 2026
- Minimum Password IncrementsOA · Seen Sep 2026
- Reduce a Number to One DigitOA · Seen Sep 2026
- Candy DistributionOA · Seen Sep 2026
- Customers Who Never OrderedOA · Seen Sep 2026
- Coin ChangeOA · Seen Sep 2026
- Validate Email AddressOA · Seen Sep 2026
- Closest Rhyming WordOA · Seen Aug 2026
- Array Leader ElementsOA · Seen Nov 2025
- Alternating Index Square SumONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Catch Fish with Reusable BaitsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Maximum Apples That Fit in a BoxVirtu Financial · OAVirtu Financial interview questions
- Server ManagementRippling · OARippling interview questions
- Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
- Minimum Pile Reduction StepsAmerican Express · OAAmerican Express interview questions
- Find Maximum Number of Subjects Passed (AS Intern, but it may apply to other interns) 🍋Amazon · OA
- Maximum Production Within PowerZomato / Eternal · OAZomato / Eternal interview questions
- Can Every Package Fit in a BoxIMC Trading · OAIMC Trading interview questions
- Compute Walking DistanceTikTok · OATikTok interview questions
- Minimum Tunnel Crossing TimeArcesium · OAArcesium interview questions