Influencers Squad
Learn this problemProblem statement
Imagine you're a community manager at TikTok, tasked with building teams for a high-stakes influencer marketing campaign. You have a list of influencers, each with an engagement score based on their recent activity. Your goal is to form the largest squad of influencers who can collaborate seamlessly.
For any team to work well together, the difference between the engagement scores of two consecutive influencers in the squad must be either 0 or 1. If the difference between consecutive influencers is greater than 1, they won't vibe well!
Given the engagement_scores of n influencers, your task is to find the largest possible squad where all members can collaborate smoothly.
Note: You are allowed to rearrange the influencers to maximize team potential!
Function
findMaxSquadSize(engagement_scores: int[]) → int
Complete the function findMaxSquadSize in the editor.
findMaxSquadSize has the following parameter:
int[] engagement_scores: an array of integers representing the engagement scores of influencers
Returns
int: the size of the largest squad
⸜(。˃ ᵕ ˂ )⸝♡ Credit to A 🌷༊·˚
Examples
Example 1
engagement_scores = [12, 14, 15, 11, 16]return = 3Example 2
engagement_scores = [1, 13, 2, 3]return = 3Example 3
engagement_scores = [10, 10, 10, 10, 11]return = 5Constraints
1 <= n <= 1051 <= engagement_scores[i] <= 109More Tiktok problems
- Count Access Code PairsOA · Seen Jul 2026
- Count Key ChangesOA · Seen Jul 2026
- Travel Distance on ScootersOA · Seen Jul 2026
- Count Skipped Numbers After SubtractionsOA · Seen Jul 2026
- Obstacle Placement QueriesOA · Seen Jul 2026
- Repeated Grouped Digit SumOA · Seen Jul 2026
- Count Cyclic Digit PairsOA · Seen Jun 2026
- Event ID Check Completion TimesOA · Seen Jun 2026