As reported: Walmart Software Engineer 3 round 1, DSA + Java (Bengaluru, 2025): LeetCode Task Scheduler II, then
pow(a, b)with binary exponentiation, then Java questions.
tasks[i] is the type of the i-th task. Tasks must be completed in order, one per day. After completing a task of some type, at least space days must pass before another task of the same type. On any day you either complete the next task or take a break. Return the minimum number of days needed.
This is LeetCode 2365 — Task Scheduler II.
Example
tasks = [1,2,1,2,3,1], space = 3 -> 9
tasks = [5,8,8,5], space = 2 -> 6
Constraints: 1 ≤ tasks.length ≤ 10^5; 1 ≤ tasks[i] ≤ 10^9; 1 ≤ space ≤ tasks.length. The answer can exceed 32 bits.
Code runner format: one JSON value per line: tasks, then space. Implement taskSchedulerII(tasks, space); the harness prints the number of days.