Maximize Collaboration
Updated
Problem statement
As a data analyst at TikTok, you've been assigned an innovative project to help maximize creator collaborations for peak viral impact. With so many creators competing for attention, each creator has their own engagement power, which measures how likely they are to boost views, likes, and shares.
Your task is to create collaboration teams where creators join forces to generate ultimate viral content. However, forming these teams follows specific rules:
- Creators must be adjacent based on their posting order. This means you can only form teams with creators who post one after the other, without skipping anyone. For example, if creators 1, 2, and 3 post consecutively, they can form a team. However, you cannot combine creators 1, 3, and 5 since they are not adjacent in the posting sequence.
- You need at least a minimum number of creators (given by
minCreatorsRequired) to form a valid team. - The total engagement power (sum of their powers) of the team must meet or exceed a threshold (given by
minTotalEngagementPowerRequired) to ensure the collaboration generates enough buzz to go viral.
Given a list of creators and their engagement powers, along with the minimum team size and target engagement power, determine the maximum number of collaborations you can create. Remember, each creator can only belong to one collaboration — once they're in a team, they cannot join another.
Complete the function createMaximumCollaborations in the editor.
createMaximumCollaborations has the following parameter(s):
int creatorsEngagementPower[n]: An array that denotes the engagement power of each creator.int minCreatorsRequired: The minimum number of creators required in a collaboration.long minTotalEngagementPowerRequired: The minimum total engagement power required for a collaboration.
int: The maximum number of collaborations that can be formed from the creators.
Function
createMaximumCollaborations(creatorsEngagementPower: int[], minCreatorsRequired: int, minTotalEngagementPowerRequired: long) → intExamples
Example 1
creatorsEngagementPower = [4, 4, 3, 6, 4, 3, 5]minCreatorsRequired = 2minTotalEngagementPowerRequired = 8return = 3One of the optimal ways to form the collaborations is to first use the first and second creators (4 + 4 = 8). Then, take the third and fourth creators (3 + 6 = 9). Finally, take the fifth, sixth, and seventh creators, with a total engagement power of (4 + 3 + 5 = 12).
Example 2
creatorsEngagementPower = [5, 4, 3, 2, 1]minCreatorsRequired = 3minTotalEngagementPowerRequired = 20return = 0No collaboration is possible in this case because the threshold value is greater than the total sum of the engagement powers of all the creators.
Example 3
creatorsEngagementPower = [4, 6, 8, 11, 9, 12]minCreatorsRequired = 2minTotalEngagementPowerRequired = 15return = 2There are n = 6 creators. Each collaboration must include at least minCreatorsRequired = 2 creators, and the total minTotalEngagementPowerRequired must be equal to 15.
- The first collaboration includes the first, second, and third creators, with a total engagement power of 4 + 6 + 8 = 18. This is above the
minTotalEngagementPowerRequired. - The second collaboration includes the fourth and fifth creators, with a total engagement power of 11 + 9 = 20.
Therefore, the maximum number of collaboration groups that can be formed is 2.
Constraints
1 ≤ n ≤ 10^51 ≤ creatorsEngagementPower[i] ≤ 10^91 ≤ minCreatorsRequired ≤ n1 ≤ minTotalEngagementPowerRequired ≤ 10^14
More TikTok interview questions
- Minimum Cost of Every K-Capable Model SetOA · Seen Nov 2026
- Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Oct 2026
- Next Greater Indices and Maximum GapPHONE SCREEN · Seen Oct 2026
- Count Subarrays with at Least K Equal-Fruit PairsOA · Seen Oct 2026
- Shell Command Counts with History ReferencesOA · Seen Oct 2026
- Count Subarrays Matching a Comparison PatternOA · Seen Sep 2026
- Product Minus Sum of DigitsOA · Seen Aug 2026
- Count 2x2 Submatrices by Black CellsOA · Seen Aug 2026
- Find All Local PeaksOA · Seen Aug 2026
- Count Case-Insensitive TripletsOA · Seen Aug 2026
Similar questions at other companies
- Maximum Non-Decreasing Array LengthVisa · OAVisa interview questions
- Maximum Sum RectangleDeloitte · OADeloitte interview questions
- Minimize Sum of Distances to WarehousesAmazon · OA
- Maximum Apples from Two Disjoint Fixed-Length SegmentsMarshall Wace · OAMarshall Wace interview questions
- Minimum Cost to Merge StonesGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Maximum Subarray SumCapital One · PHONE SCREEN · ONSITE INTERVIEWCapital One interview questions
- Largest All-One Square Area and CountNVIDIA · PHONE SCREENNVIDIA interview questions
- Split Array to Minimize the Largest SumInfosys · OAInfosys interview questions
- Largest Consistent Visiting GroupAuxoAI · OA
- Delete K Subsets for Maximum ScoreRubrik · OARubrik interview questions
TikTok interview experiences
- TikTok AI Infra Intern LLM Round 2: 1 Experience
- TikTok AI Infra Intern DeepSpeed Round: 1 Experience
- TikTok AI Infra Intern Kernel Round: 1 Experience
- TikTok AI Infra Intern Interviews, 3 Rounds: 1 Experience
- TikTok AI Infra Intern Interview Timeline: 1 Experience
- TikTok AI Infra Intern Onsite Round 2: 1 Experience