As reported: Wayfair Senior Software Engineer online assessment on HackerRank (2025): two questions; this one carried 70 marks. The same OA (task scheduling plus IP address classification) was reported for an L3 backend role in Bangalore.
You are given an array taskMemory of n positive integers — the memory each task needs — an array taskType of n positive integers — the type of each task — and an integer maxMemory.
Every task takes 1 unit of time to process. The server processes tasks one at a time, except that it can process at most two tasks in parallel when they are of the same type and together need no more than maxMemory units of memory.
Return the minimum amount of time needed to process all the tasks.
Example 1
taskMemory = [1,4,5,2,3], taskType = [1,2,1,3,4], maxMemory = 6 -> 4
The two type-1 tasks (memory 1 and 5, total 6) run together; the other three run alone: 1 + 3 = 4.
Example 2
taskMemory = [4,2,3,1,6,5], taskType = [1,1,2,2,1,2], maxMemory = 8 -> 4
Type 1 has memory 2, 4, 6: 2 + 6 run together, 4 alone. Type 2 has 1, 3, 5: 1 + 5 together, 3 alone. Total 4.
Constraints: 1 ≤ n ≤ 10^5; 1 ≤ taskType[i] ≤ 10^9; 1 ≤ taskMemory[i] ≤ maxMemory ≤ 10^9.
Code runner format: three lines: taskMemory, taskType (JSON arrays) and maxMemory. Implement getMinTime(taskMemory, taskType, maxMemory); the harness prints the answer.