Meeting room free hours
A meeting room packs one day of its calendar into a single integer. Bit h of that word, counting the least significant bit as bit 0, is set when hour h is already booked, and the hours of a day run from 0 to 23. Bits 24 and above carry unrelated housekeeping and must be ignored, even when they are set. busy_masks holds one word per day. Return one entry per day, in the order the days are given, holding the earliest hour at which a free block of hours_needed consecutive hours starts. The whole block has to sit inside the day, so it ends at hour 23 or earlier. Return -1 for a day with no such block, which covers every day when hours_needed is more than 24. hours_needed is never negative, and 0 means nothing to book, so every day answers 0.
earliest_free_hour(busy_masks: list[int], hours_needed: int) → list[int][[511,0],3]out[9,0][[16777215],1]out[-1][[12,0,4095],5]out[4,0,12]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.
[[511,0],3][9,0]not run yetsample[[16777215],1][-1]not run yetsample[[12,0,4095],5][4,0,12]not run yetsample