Charge sessions by block
A media platform meters playback in whole aligned blocks of block seconds counted from launch, so the block holding second t is numbered t divided by block, rounded down. Session i plays from starts[i] up to but not including ends[i], both non negative second counts, and is charged for every block it touches even when it touches only a sliver of one. A session whose bounds match touches nothing. Charged separately, the bill totals every session's touched blocks. Folded onto one connection, a block touched by two or more sessions is charged a single time. Sessions arrive unsorted, second counts reach 10^9 and block is at least 1, so walking blocks one at a time is hopeless. Return how many blocks folding would save.
saved_billing_blocks(starts: list[int], ends: list[int], block: int) → int[[0,90],[100,150],60]out1[[5,50],[10,55],60]out1[[0,60],[60,120],60]out0State 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.
[[0,90],[100,150],60]1not run yetsample[[5,50],[10,55],60]1not run yetsample[[0,60],[60,120],60]0not run yetsample