Optimizing TikTok Collectible Packs
Learn this problemProblem statement
ByteDance has launched a new feature on TikTok called "TikTok Collectibles," where users can collect and trade digital cards featuring popular TikTok creators. Each creator has different categories of cards, such as rare cards for the most followed creators, special edition cards with unique designs, and interactive cards that come with exclusive video content.
ByteDance wants to create a number of collectible packs, each containing equal numbers of each type of card. To achieve this, they need to add more cards to ensure each type can be evenly distributed across the packs.
Given the current inventory of each category of cards as an integer array cardTypes of size n, determine the minimum number of additional cards needed so that they can create more than one pack with an equal type distribution.
Function
cardPackets(cardTypes: int[]) → int
Complete the function cardPackets in the editor.
cardPackets has the following parameter(s):
int cardTypes[n]: the quantity available of card type
Returns
int: the minimum number of additional cards to add
Examples
Example 1
cardTypes = [4, 7, 5, 11, 15]return = 4Example 2
cardTypes = [3, 8, 7, 6, 4]return = 2Example 3
cardTypes = [3, 9, 7, 6, 5, 2]return = 4Constraints
1 ≤ n ≤ 10^51 ≤ cardTypes[i] ≤ 500
More 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