Heap file page waste
A relational engine keeps a table in a heap file built from fixed size pages. Every page reserves header_bytes at its start for bookkeeping, and the rest of the page holds row data. Rows are appended in the order given, and a row is never split across two pages: when a row does not fit in the space left on the open page, the engine closes that page and starts a fresh one. It never goes back to an earlier page. Each entry of rows is one row written as "row_id|width", where width is that row's size in bytes. Return the wasted space of every page the engine wrote, in page order, where wasted space means the bytes of that page still free after the last row it holds. Return an empty list when there are no rows. Every row is small enough to fit in an empty page.
page_slack_bytes(rows: list[str], page_bytes: int, header_bytes: int) → list[int][["r1|300","r2|300","r3|300"],1024,24]out[100][["r1|400","r2|400","r3|400"],1024,24]out[200,600][["a|500","b|500","c|10"],1024,24]out[0,990]State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["r1|300","r2|300","r3|300"],1024,24][100]not run yetsample[["r1|400","r2|400","r3|400"],1024,24][200,600]not run yetsample[["a|500","b|500","c|10"],1024,24][0,990]not run yetsample