Grokking Data Structures & Algorithms for Coding Interviews
Vote

0% completed

Minimize the Maximum of Two Arrays (medium)

Problem Statement

Given divisor1, divisor2, uniqueCnt1, and uniqueCnt2 integers, find the smallest possible maximum integer that could be present in either array after they are filled according to the below conditions.

  • You can take two arrays arr1 and arr2 which are initially empty.
  • arr1 contains total uniqueCnt1 different positive integers, each of them is not divisible by divisor1.
  • arr2 contains total uniqueCnt2 different positive integers, each of them is not divisible by divisor2.
  • There are no common integers in both arrays.

.....

.....

.....

Like the course? Get enrolled and start learning!
Uma Maheswaran M

Uma Maheswaran M

· 2 years ago

In an edge case, when both arrays couldn't be filled with number as both divisors are 1, result is expected to be (uniqueCount1*uniqueCount2)+1. But it is not clearly mentioned in the question.

Show 1 reply
Madhusudan Anand

Madhusudan Anand

· 4 months ago

Based on

Constraints:

  • 2 <= divisor1, divisor2 <= 105
  • 1 <= uniqueCnt1, uniqueCnt2 < 109
  • 2 <= uniqueCnt1 + uniqueCnt2 <= 109

Test case 1 100 1 200

is wrong kindly remove it