Amazon OA questions countMaximumTeams

Hi,

I got Amazon questions countMaximumTeams. Given an skill array example - [3,4,3,1,6,5] and teamSize = 3 and maxDiff =2.
public int countMaximumTeams(List skill,int teamSize, int maxDiff)

Target: So, Try to form maximum teams size 3 each, e.g., here 2 team1 = [3,3,1] ( As max skill (3) differ from min. skill(1)=3-1 = 2) - so this is valid combination. Other team2 = [4,6,5] (as max skill(6) - min.skill(4)=2) - so this one is valid too. Maximum two combination or teams can be form

Output: 2

Comments (6)