Company: Ion group_26july
Difficulty: medium
Minimum Time to Process Tasks Problem Description Given an array taskMemory of n positive integers representing memory required for each task, an array taskType of n positive integers representing task types, and an integer maxMemory , find the minimum time required to process all tasks. Each task takes 1 unit of time. The server can process at most two tasks in parallel only if they are the same type and together require no more than maxMemory units. Examples Example 1: Input: n = 4, taskMemory = [7,2,3,9], taskType = [1,2,1,3], maxMemory = 10 Output: 3 Explanation: Tasks 0 (memory 7, type 1) and 2 (memory 3, type 1) can be processed concurrently as they are of the same type and their combined memory (7 + 3 = 10) does not exceed maxMemory . This takes 1 unit of time. The remaining tasks (1 and 3) must be processed individually, each taking 1 unit of time. Task 1 (memory 2, type 2) takes 1 unit. Task 3 (memory 9, type 3) takes 1 unit. Therefore, the total minimum time required is 1 (fo