Checkpoint dirty pages
A storage engine is taking a checkpoint. Its dirty page table holds one entry per change that sits in memory and not yet on disk, written as "p7|412": a page id, a pipe, then the log sequence number of that change. A page id can appear several times, and the number that matters for a page is the smallest one it carries, the oldest change it has not written out. The checkpoint writes every page whose smallest number is at most checkpoint_lsn. A written page costs page_bytes and afterwards carries nothing. Every other page stays dirty. Return three numbers in this order: how many pages were written, how many bytes those writes cost, and the restart point, which is the smallest number still carried by a page left dirty, or checkpoint_lsn when no page is left dirty.
checkpoint_flush_plan(dirty_pages: list[str], checkpoint_lsn: int, page_bytes: int) → list[int][["p1|100","p2|250","p3|400"],300,8192]out[2,16384,400][["p4|900","p4|120","p5|950"],500,4096]out[1,4096,950][["p7|700","p8|860"],500,4096]out[0,0,700]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.
[["p1|100","p2|250","p3|400"],300,8192][2,16384,400]not run yetsample[["p4|900","p4|120","p5|950"],500,4096][1,4096,950]not run yetsample[["p7|700","p8|860"],500,4096][0,0,700]not run yetsample