Identical Distribution

Company: Adobe_12oct

Difficulty: medium

Problem Statement

Identical Distribution Problem Description An e-commerce company needs to create packets of sports cards, with each packet containing an equal number of each card type. Given an array representing the current quantity of each card type, find the minimum number of cards that must be added so that all types can be evenly distributed among a number of packets greater than 1. Complete the function cardPackets in the editor with 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: Input: cardTypes = [4, 7, 5, 11, 15] Output: 4 Explanation: To create 2 packets: Add [0, 1, 1, 1, 1] cards = 4 additional cards. Final quantities: [4, 8, 6, 12, 16]. To create 3 packets: Add [2, 2, 1, 1, 0] cards = 6 additional cards. Final quantities: [6, 9, 6, 12, 15]. The minimum number of cards to add is 4 to create 2 packets. Example 2: Input: cardTypes = [3, 8, 7, 6, 4] Output: 2 Explanation: For 2 p