Minimum Team Size Covering All Talents
viaLeetCode
There are n students, each with a talent value in [1, talentCount] given by talent[]. A valid group must consist of continuous students and include at least one student of every talent from 1 to talentCount. For each starting index i, find res[i] = the minimum number of consecutive students (starting at i) needed to form a valid group (-1 if impossible). Sliding-window / two-pointer expanding from each start while tracking distinct talents covered.
asked …