2513. Minimize the Maximum of Two Arrays Medium
1/**
2 * [2513] Minimize the Maximum of Two Arrays
3 *
4 * We have two arrays arr1 and arr2 which are initially empty. You need to add positive integers to them such that they satisfy all the following conditions:
5 *
6 * arr1 contains uniqueCnt1 distinct positive integers, each of which is not divisible by divisor1.
7 * arr2 contains uniqueCnt2 distinct positive integers, each of which is not divisible by divisor2.
8 * No integer is present in both arr1 and arr2.
9 *
10 * Given divisor1, divisor2, uniqueCnt1, and uniqueCnt2, return the minimum possible maximum integer that can be present in either array.
11 *
12 * <strong class="example">Example 1:
13 *
14 * Input: divisor1 = 2, divisor2 = 7, uniqueCnt1 = 1, uniqueCnt2 = 3
15 * Output: 4
16 * Explanation:
17 * We can distribute the first 4 natural numbers into arr1 and arr2.
18 * arr1 = [1] and arr2 = [2,3,4].
19 * We can see that both arrays satisfy all the conditions.
20 * Since the maximum value is 4, we return it.
21 *
22 * <strong class="example">Example 2:
23 *
24 * Input: divisor1 = 3, divisor2 = 5, uniqueCnt1 = 2, uniqueCnt2 = 1
25 * Output: 3
26 * Explanation:
27 * Here arr1 = [1,2], and arr2 = [3] satisfy all conditions.
28 * Since the maximum value is 3, we return it.
29 * <strong class="example">Example 3:
30 *
31 * Input: divisor1 = 2, divisor2 = 4, uniqueCnt1 = 8, uniqueCnt2 = 2
32 * Output: 15
33 * Explanation:
34 * Here, the final possible arrays can be arr1 = [1,3,5,7,9,11,13,15], and arr2 = [2,6].
35 * It can be shown that it is not possible to obtain a lower maximum satisfying all conditions.
36 *
37 *
38 * Constraints:
39 *
40 * 2 <= divisor1, divisor2 <= 10^5
41 * 1 <= uniqueCnt1, uniqueCnt2 < 10^9
42 * 2 <= uniqueCnt1 + uniqueCnt2 <= 10^9
43 *
44 */
45pub struct Solution {}
46
47// problem: https://leetcode.com/problems/minimize-the-maximum-of-two-arrays/
48// discuss: https://leetcode.com/problems/minimize-the-maximum-of-two-arrays/discuss/?currentPage=1&orderBy=most_votes&query=
49
50// submission codes start here
51
52impl Solution {
53 pub fn minimize_set(divisor1: i32, divisor2: i32, unique_cnt1: i32, unique_cnt2: i32) -> i32 {
54 0
55 }
56}
57
58// submission codes end
59
60#[cfg(test)]
61mod tests {
62 use super::*;
63
64 #[test]
65 fn test_2513() {
66 }
67}
68
Back
© 2025 bowen.ge All Rights Reserved.