Influencers Squad
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!
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 🌷༊·˚
1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
1 <= n <= 1051 <= engagement_scores[i] <= 109