The downstream API takes a request of at most budget bytes. Rows have to go out in order, packed into as few requests as possible.
rows — a list of (row_id, size_bytes), in the order they must be sentbudget — int, the most a single batch may carryA list of (batch_index, row_id) — the batch each row was placed in, numbered from 0 in the order batches are opened. Order is not graded.
rows[[1, 40], [2, 40], [3, 40]]
budget100
[[0, 1], [0, 2], [1, 3]]
rows[[1, 60], [2, 40], [3, 10]]
budget100
[[0, 1], [0, 2], [1, 3]]
Community-reported interview topic. Not an official company question and no affiliation is implied.
Run against the public tests, or submit to score against all of them.