Tallest safe pallet column
A warehouse stacks pallets into one column. Pallet i weighs weight[i] kilograms, and crush[i] is the most weight it can carry above it before it fails. A column is safe when every pallet in it carries no more than its own crush rating, counting the weight of all the pallets above it and not its own weight. You choose which pallets go into the column and in what order, and the pallets left out stay on the floor. Return the largest number of pallets one safe column can hold. The two lists have the same length, every weight is at least one, every crush rating is at least zero, and an empty yard gives 0. Working out the order first is what makes the choice tractable.
tallest_pallet_column(weight: list[int], crush: list[int]) → int[[3,2,5],[10,2,1]]out2[[1,1,1],[5,5,5]]out3[[4,4],[0,0]]out1State 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.
[[3,2,5],[10,2,1]]2not run yetsample[[1,1,1],[5,5,5]]3not run yetsample[[4,4],[0,0]]1not run yetsample