Heap file page waste

Write codeEasy15 minOracle and Snowflake style

Your task

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.

Examples

page_slack_bytes(rows: list[str], page_bytes: int, header_bytes: int) -> list[int]
Example 1
Inputpage_slack_bytes(["r1|300", "r2|300", "r3|300"], 1024, 24)
Output[100]
Example 2
Inputpage_slack_bytes(["r1|400", "r2|400", "r3|400"], 1024, 24)
Output[200, 600]
Example 3
Inputpage_slack_bytes(["a|500", "b|500", "c|10"], 1024, 24)
Output[0, 990]