Tap here to switch tabs
Problem
Submissions

Problem: Minimize the Maximum of Two Arrays

med
30 min
Try to solve the Minimize the Maximum of Two Arrays problem.

Statement

You are given two positive integers, divisor1 and divisor2, along with two integers, uniqueCnt1 and uniqueCnt2.

You must populate two arrays, arr1 and arr2, with distinct positive integers such that:

  • arr1 contains uniqueCnt1 unique integers, none of which are divisible by divisor1.

  • arr2 contains uniqueCnt2 unique integers, none of which are divisible by divisor2.

  • arr1 and arr2 are disjoint, meaning no integer appears in both arrays.

Return the minimum possible maximum value present across both arrays after choosing the elements optimally.

Constraints:

  • 2≤2 \leq divisor1, divisor2 ≤105\leq 10^5

  • 1≤1 \leq uniqueCnt1, uniqueCnt2 <109< 10^9

  • 2≤2 \leq uniqueCnt1 ++ uniqueCnt2 ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimize the Maximum of Two Arrays

med
30 min
Try to solve the Minimize the Maximum of Two Arrays problem.

Statement

You are given two positive integers, divisor1 and divisor2, along with two integers, uniqueCnt1 and uniqueCnt2.

You must populate two arrays, arr1 and arr2, with distinct positive integers such that:

  • arr1 contains uniqueCnt1 unique integers, none of which are divisible by divisor1.

  • arr2 contains uniqueCnt2 unique integers, none of which are divisible by divisor2.

  • arr1 and arr2 are disjoint, meaning no integer appears in both arrays.

Return the minimum possible maximum value present across both arrays after choosing the elements optimally.

Constraints:

  • 2≤2 \leq divisor1, divisor2 ≤105\leq 10^5

  • 1≤1 \leq uniqueCnt1, uniqueCnt2 <109< 10^9

  • 2≤2 \leq uniqueCnt1 ++ uniqueCnt2 ≤109\leq 10^9