1655. Distribute Repeating Integers Hard

@problem@discussion
#Array#Dynamic Programming#Backtracking#Bit Manipulation#Bitmask



1/**
2 * [1655] Distribute Repeating Integers
3 *
4 * You are given an array of n integers, nums, where there are at most 50 unique values in the array. You are also given an array of m customer order quantities, quantity, where quantity[i] is the amount of integers the i^th customer ordered. Determine if it is possible to distribute nums such that:
5 * 
6 * 	The i^th customer gets exactly quantity[i] integers,
7 * 	The integers the i^th customer gets are all equal, and
8 * 	Every customer is satisfied.
9 * 
10 * Return true if it is possible to distribute nums according to the above conditions.
11 *  
12 * Example 1:
13 * 
14 * Input: nums = [1,2,3,4], quantity = [2]
15 * Output: false
16 * Explanation: The 0^th customer cannot be given two different integers.
17 * 
18 * Example 2:
19 * 
20 * Input: nums = [1,2,3,3], quantity = [2]
21 * Output: true
22 * Explanation: The 0^th customer is given [3,3]. The integers [1,2] are not used.
23 * 
24 * Example 3:
25 * 
26 * Input: nums = [1,1,2,2], quantity = [2,2]
27 * Output: true
28 * Explanation: The 0^th customer is given [1,1], and the 1st customer is given [2,2].
29 * 
30 *  
31 * Constraints:
32 * 
33 * 	n == nums.length
34 * 	1 <= n <= 10^5
35 * 	1 <= nums[i] <= 1000
36 * 	m == quantity.length
37 * 	1 <= m <= 10
38 * 	1 <= quantity[i] <= 10^5
39 * 	There are at most 50 unique values in nums.
40 * 
41 */
42pub struct Solution {}
43
44// problem: https://leetcode.com/problems/distribute-repeating-integers/
45// discuss: https://leetcode.com/problems/distribute-repeating-integers/discuss/?currentPage=1&orderBy=most_votes&query=
46
47// submission codes start here
48
49impl Solution {
50    pub fn can_distribute(nums: Vec<i32>, quantity: Vec<i32>) -> bool {
51        false
52    }
53}
54
55// submission codes end
56
57#[cfg(test)]
58mod tests {
59    use super::*;
60
61    #[test]
62    fn test_1655() {
63    }
64}
65


Back
© 2025 bowen.ge All Rights Reserved.