Panda Guru LogoPanda
Guru

UKG OA Problem

Round 1

Questions: You are given an array processSize of length n where each element represents the size of a process, and an array capacity of length m where each element represents the capacity of a processor. The processors can execute processes concurrently, and each processor takes 1 second to execute a process. After executing a process, a processor will pause for 1 second before executing another one.

Your task is to find the minimum time required to execute all the processes using the processors, or return -1 if it is impossible to execute all processes.

Input:

Output: Return an integer representing the minimum time required to execute all processes, or -1 if it is impossible to execute all processes.

Constraints: 1 ≤ n, m ≤ 2 * 10^5
1 ≤ processSize[i], capacity[i] ≤ 10^9

Example: Example 1:

Input: processSize = [2, 5, 1] capacity = [3, 4, 1] Output: 1 Explanation: The optimal way to assign processes is to give the first processor the first process, the second processor the second process, and the third processor the third process. All of them complete their processes in 1 second.

Example 2:

Input: processSize = [2, 5, 1] capacity = [2, 4, 1] Output: -1 Explanation: The first processor cannot handle the process of size 5, so it's impossible to execute all processes.
Candidate's Approach

No approach provided.

Interviewer's Feedback

No feedback provided.