Maximum Planes Destroyed Before Landing
Problem statement
There are n hostile planes. Plane i starts at positive height heights[i] and descends by descent[i] height units per minute.
At minute 0, and then once at the start of every following minute, you may destroy one plane. If any remaining plane has reached ground level at or before that minute, the defense ends before you can fire. Return the maximum number of planes you can destroy.
Function
maximumPlanesDestroyed(heights: int[], descent: int[]) → intExamples
Example 1
heights = [1,3,4]descent = [1,1,1]return = 3The landing deadlines are minutes 1, 3, and 4, so all three can be destroyed at minutes 0, 1, and 2.
Example 2
heights = [1,1,2]descent = [1,1,1]return = 1After one shot at minute 0, another plane reaches ground at minute 1.
Constraints
1 <= heights.length == descent.length <= 100000.1 <= heights[i], descent[i] <= 10^9.