Tracks in Hackathon
Learn this problemProblem statement
There is a hackathon organized by HackerRank which has 2 separate tracks, healthcare and e-commerce. For track 1, the required team size is teamSize_1, while for track 2, the required team size is teamSize_2. The total number of participants is p.
Find the minimum number of teams into which the participants can be divided such that each participant belongs to exactly one team (either of track 1 or track 2), and each team has a size equal to either teamSize_1 or teamSize_2. If no such division is possible, return -1.
Function
countTeams(teamSize_1: int, teamSize_2: int, p: int) → int
Complete the function countTeams in the editor.
The function countTeams has the following parameters:
int teamSize_1: the number of participants in teams of track 1int teamSize_2: the number of participants in teams of track 2int p: the total number of participants
Returns
int: the minimum number of teams into which the participants can be divided
Examples
Example 1
teamSize_1 = 3teamSize_2 = 4p = 7return = 2Optimally there is 1 team of 3 and 1 team of 4. The minimum number of teams is 2.
Constraints
- 1 ≤
teamSize_1,teamSize_2≤ 10^5 - 1 ≤
p≤ 10^5
More JPMorgan Chase problems
- Bitwise XOR SubsequencesOA · Seen Jul 2026
- Array ChallengeOA · Seen Jun 2026
- Minimum Cores to Handle ProcessesOA · Seen Jun 2026
- About ShippingOA · Seen Jun 2026
- Count Dropped RequestsOA · Seen Jan 2026
- Generate Table of ContentsOA · Seen Jan 2026
- Calculate Net ProfitSeen Jun 2025
- Find Total WeightSeen Jun 2025