Tracks in Hackathon
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.
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
1Example 1
Optimally there is 1 team of 3 and 1 team of 4. The minimum number of teams is 2.
Constraints
Limits and guarantees your solution can rely on.
- 1 ≤
teamSize_1,teamSize_2≤ 10^5 - 1 ≤
p≤ 10^5