Problem · Array
Minimum Team Size From Every Start
Learn this problemProblem statement
Students stand in a fixed order. talent[i] is an integer from 1 through talentsCount.
For every starting index, choose a consecutive group beginning there that contains every talent at least once. Return the minimum possible group length for each start, or -1 when the remaining suffix cannot form a complete team.
Function
teamSize(talent: int[], talentsCount: int) → int[]Examples
Example 1
talent = [1,2,3,2,1]talentsCount = 3return = [3,4,3,-1,-1]The shortest complete windows starting at the first three positions have lengths 3, 4, and 3. The last two suffixes miss at least one talent.
Constraints
1 <= talent.length, talentsCount <= 2000001 <= talent[i] <= talentsCount