Class Solution
- java.lang.Object
-
- g1601_1700.s1655_distribute_repeating_integers.Solution
-
public class Solution extends Object
1655 - Distribute Repeating Integers.Hard
You are given an array of
nintegers,nums, where there are at most50unique values in the array. You are also given an array ofmcustomer order quantities,quantity, wherequantity[i]is the amount of integers theithcustomer ordered. Determine if it is possible to distributenumssuch that:- The
ithcustomer gets exactlyquantity[i]integers, - The integers the
ithcustomer gets are all equal , and - Every customer is satisfied.
Return
trueif it is possible to distributenumsaccording to the above conditions.Example 1:
Input: nums = [1,2,3,4], quantity = [2]
Output: false
Explanation: The 0th customer cannot be given two different integers.
Example 2:
Input: nums = [1,2,3,3], quantity = [2]
Output: true
Explanation: The 0th customer is given [3,3]. The integers [1,2] are not used.
Example 3:
Input: nums = [1,1,2,2], quantity = [2,2]
Output: true
Explanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].
Constraints:
n == nums.length1 <= n <= 1051 <= nums[i] <= 1000m == quantity.length1 <= m <= 101 <= quantity[i] <= 105- There are at most
50unique values innums.
- The
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanDistribute(int[] nums, int[] quantity)
-