Company: Toast_24nov
Difficulty: medium
Toast's Efficient Teams Problem Description Toast has 2 * n employees. The i -th employee has an efficiency equal to i , for i = 1, 2, ..., 2 * n , so the available efficiencies are exactly the integers from 1 to 2 * n , each appearing once. Toast wants to organise these employees into n teams of exactly 2 members each, with every employee assigned to exactly one team. Each team performs one of two task types: Task Type 1 : the team's efficiency is the minimum efficiency of its two members. Task Type 2 : the team's efficiency is the maximum efficiency of its two members. Toast picks a number x with 0 <= x <= n . The first x teams perform Task Type 1 and the remaining n - x teams perform Task Type 2. The goal is that the j -th team ( 0 -based) ends up with efficiency exactly totalEfficiency[j] . Given n and the strictly increasing array totalEfficiency , determine how many values of x in the range 0 <= x <= n allow the whole target array to be achieved. For each value of x ,