Quota file count
A backup service uploads a night of files to cold storage in a fixed manifest order. sizes gives each file's size in bytes in that order, and a size can be 0, because empty files happen. An operations dashboard asks the same manifest about several byte quotas at once. For each entry of quotas, return how many files, counted from the front of the manifest, have to be uploaded before the running total first reaches that quota. Return -1 for a quota the whole manifest never reaches. Every quota is at least 1. Return one answer per quota, in the order the quotas are given, and return an empty list when no quotas are asked. A manifest holds millions of files and the dashboard asks many quotas, so re-adding the sizes once per quota is too slow.
files_needed_for_quotas(sizes: list[int], quotas: list[int]) → list[int][[400,100,250,50],[400,500,800]]out[1,2,4][[120,30],[200]]out[-1][[],[1]]out[-1]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.
[[400,100,250,50],[400,500,800]][1,2,4]not run yetsample[[120,30],[200]][-1]not run yetsample[[],[1]][-1]not run yetsample