Trains the technique from
LeetCode 2402Meeting Rooms IIIThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A dye house owns vats interchangeable vats, numbered 0 through vats - 1.
batches[i] = [begin, finish] is a booked batch that asks for a vat at time begin and would hand it back at time finish. The batches are not listed in any particular order, but no two of them ask for a vat at the same time.
The floor supervisor deals with the batches in increasing order of their begin time. When a batch's turn comes:
finish - begin. Should more than one vat be handed back at that same instant, the batch takes the smallest of their numbers.A vat counts as idle again at the very instant a batch hands it back, so a batch asking for a vat at that instant may use it.
Return the number of the vat that handles the most batches. When several vats handle that same number of batches, return the smallest of their numbers.
Example 1
The batch beginning at 0 goes into vat 0 and hands it back at 5. The batch beginning at 1 finds vat 0 occupied and goes into vat 1, handing it back at 3. At time 6 both vats are idle, so the last batch goes into vat 0. Vat 0 handled two batches and vat 1 handled one.
Example 2
Vats 0 and 1 are taken until time 100 by the first two batches. Each of the three short batches finds those two occupied and vat 2 idle, so vat 2 handles three batches while the others handle one each.
Example 3
One batch goes into each vat, so both handled one batch and the smaller vat number is reported.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def busiest_dye_vat(vats: int, batches: list[list[int]]) -> int:public int busiestDyeVat(int vats, int[][] batches)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.