Skip to content

Practice Minimize the Maximum of Two Arrays

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2513
LeetCode Problem

Minimize the Maximum of Two Arrays

Problem Statement

Choose two disjoint sets of positive integers. The first must have uniqueCnt1 values, none divisible by divisor1; the second must have uniqueCnt2 values, none divisible by divisor2. Return the smallest achievable maximum value across both sets.

Source: Minimize the Maximum of Two Arrays on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
divisor1 = 2, divisor2 = 7, uniqueCnt1 = 1, uniqueCnt2 = 3
Output
4

# Example 2

Input
divisor1 = 3, divisor2 = 5, uniqueCnt1 = 2, uniqueCnt2 = 1
Output
3

# Example 3

Input
divisor1 = 2, divisor2 = 4, uniqueCnt1 = 8, uniqueCnt2 = 2
Output
15

Constraints

2 <= divisor1, divisor2 <= 10^5
1 <= uniqueCnt1, uniqueCnt2 < 10^9
2 <= uniqueCnt1 + uniqueCnt2 <= 10^9

Related LeetCode Problems

Practice more problems similar to Minimize the Maximum of Two Arrays.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.