2dbi

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.

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account