Maximum Planes Destroyed Before Landing
Updated
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 = 3Each plane drops one unit per minute, so the planes reach the ground at minutes 1, 3, and 4. Shoot them at minutes 0, 1, and 2, before each one lands. All three planes are destroyed, so the answer is three.
Example 2
heights = [1,1,2]descent = [1,1,1]return = 1The first two planes would land at the same time. You can shoot only one of them at minute 0. The other one reaches the ground at minute 1, so the defense ends before your next shot. Only one plane is destroyed, so the answer is one.
Constraints
1 <= heights.length == descent.length <= 100000.1 <= heights[i], descent[i] <= 10^9.
More Agoda Phone Screen questions
- Sort Ones, Twos, and Threes In PlacePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Can Place FlowersPHONE SCREEN · Seen Nov 2026
- Reverse Words in a StringPHONE SCREEN · Seen Nov 2026
- Disk Space Window AnalyzerPHONE SCREEN · Seen Sep 2026
- Shortest Subarray With the Full DegreePHONE SCREEN · Seen Sep 2026
- Enumerate Weekly Work SchedulesPHONE SCREEN · Seen Sep 2026
- Count Values Appearing Exactly OncePHONE SCREEN · Seen Sep 2026
- Longest All-Present Attendance StreakPHONE SCREEN · Seen Sep 2026
- Chemical Formula WeightPHONE SCREEN · Seen Sep 2026
- Find the Pivot ElementPHONE SCREEN · Seen Sep 2026
Similar questions at other companies
- Fair Capped Money DistributionGusto · PHONE SCREEN · ONSITE INTERVIEWGusto interview questions
- Tennis Court SchedulingAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Maximum Number of Events That Can Be AttendedByteDance · PHONE SCREENByteDance interview questions
- Remove the Fewest Magic BeansThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions
- Aggressive CowsAmazon · PHONE SCREEN
- Minimize Range After Three ChangesDRW · PHONE SCREENDRW interview questions
- Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
- Experiment Bucket Allocation and RebalancingPinterest · PHONE SCREENPinterest interview questions
- Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
- Minimum Appointment Cancellations with a Required BreakMaven Clinic · PHONE SCREENMaven Clinic interview questions