Optimizing TikTok Collectible Packs
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.
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
1Example 1
2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
1 ≤ n ≤ 10^51 ≤ cardTypes[i] ≤ 500