Class Solution
java.lang.Object
g1601_1700.s1655_distribute_repeating_integers.Solution
1655 - Distribute Repeating Integers.<p>Hard</p>
<p>You are given an array of <code>n</code> integers, <code>nums</code>, where there are at most <code>50</code> unique values in the array. You are also given an array of <code>m</code> customer order quantities, <code>quantity</code>, where <code>quantity[i]</code> is the amount of integers the <code>i<sup>th</sup></code> customer ordered. Determine if it is possible to distribute <code>nums</code> such that:</p>
<ul>
<li>The <code>i<sup>th</sup></code> customer gets <strong>exactly</strong> <code>quantity[i]</code> integers,</li>
<li>The integers the <code>i<sup>th</sup></code> customer gets are <strong>all equal</strong> , and</li>
<li>Every customer is satisfied.</li>
</ul>
<p>Return <code>true</code> <em>if it is possible to distribute</em> <code>nums</code> <em>according to the above conditions</em>.</p>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [1,2,3,4], quantity = [2]</p>
<p><strong>Output:</strong> false</p>
<p><strong>Explanation:</strong> The 0<sup>th</sup> customer cannot be given two different integers.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [1,2,3,3], quantity = [2]</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> The 0<sup>th</sup> customer is given [3,3]. The integers [1,2] are not used.</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [1,1,2,2], quantity = [2,2]</p>
<p><strong>Output:</strong> true</p>
<p><strong>Explanation:</strong> The 0<sup>th</sup> customer is given [1,1], and the 1st customer is given [2,2].</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>n == nums.length</code></li>
<li><code>1 <= n <= 10<sup>5</sup></code></li>
<li><code>1 <= nums[i] <= 1000</code></li>
<li><code>m == quantity.length</code></li>
<li><code>1 <= m <= 10</code></li>
<li><code>1 <= quantity[i] <= 10<sup>5</sup></code></li>
<li>There are at most <code>50</code> unique values in <code>nums</code>.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
canDistribute
public boolean canDistribute(int[] nums, int[] quantity)
-