There are n developers, where the skill level of the ith developer is given by i, for 1 ≤ i ≤ n.
A developer agrees to be on the team only if certain conditions are met. Given two arrays, lowerSkill and higherSkill, the ith developer will join the team if at most lowerSkill[i] team members have a lower skill level than them, and at most higherSkill[i] team members have a higher skill level than them.
The objective is to select the largest possible team such that every developer on the team agrees with the team composition based on these conditions.
Given n = 5, lowerSkill = [1,3,2,2,2] higherSkill = [2,2,1,1,3]
It is optimal to select developers with skill levels 1, 3, and 4. For the developer with skill level 1, there are two developers with higher skill levels and lowerSkill[1] = 2 . For the developer with skill level 3, there is one developer with a lower skill level and one with a higher skill level with higherSkill[3]=[1] . For the developer with skill level 4, there are two developers with lower skill levels. Thus, all three developers are content. Hence, the number of developers selected for the hackathon team will be 3. It can be shown that this is the maximum possible number of developers that can be selected under these conditions.
Complete the function getOptimalTeamSize in the editor below.