BudiBadu Logo
00:00

Festival Drone Altitude Limit

Binary Search Easy 27 views

The festival controls camera drones that rise above the pier to capture lantern formations. Engineers have a testing log showing, for selected altitudes, whether the control signal remained stable. The log is monotonic: once the signal fails at a certain altitude, every higher altitude also fails. The director must know the highest altitude that still maintains a stable signal so the drone team can plan sweeping shots without risking a drop.

You receive the altitude values and a parallel boolean array indicating stability outcomes (true for stable, false for unstable), and the altitudes are strictly increasing. Determine the largest altitude with a stable signal; return -1 if the first altitude already fails. Implement the search with binary search, leaving the inputs untouched. This quick assessment helps the camera crew choreograph drone paths, set safety ceilings, and reassure performers that aerial shots will trace the lantern glow safely.

Example 1:

Input: altitudes = [50,80,120], stable = [true,true,false]
Output: 80
Explanation: Altitude 80 is the last stable value before failure at 120.

Example 2:

Input: altitudes = [30,60], stable = [false,false]
Output: -1
Explanation: All tested altitudes fail, so no safe flight ceiling exists.

Example 3:

Input: altitudes = [], stable = []
Output: -1
Explanation: Without test data, no safe altitude can be confirmed.

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.

BudiBadu Logo

Festival Drone Altitude Limit

Binary Search Easy 27 views

The festival controls camera drones that rise above the pier to capture lantern formations. Engineers have a testing log showing, for selected altitudes, whether the control signal remained stable. The log is monotonic: once the signal fails at a certain altitude, every higher altitude also fails. The director must know the highest altitude that still maintains a stable signal so the drone team can plan sweeping shots without risking a drop.

You receive the altitude values and a parallel boolean array indicating stability outcomes (true for stable, false for unstable), and the altitudes are strictly increasing. Determine the largest altitude with a stable signal; return -1 if the first altitude already fails. Implement the search with binary search, leaving the inputs untouched. This quick assessment helps the camera crew choreograph drone paths, set safety ceilings, and reassure performers that aerial shots will trace the lantern glow safely.

Example 1:

Input: altitudes = [50,80,120], stable = [true,true,false]
Output: 80
Explanation: Altitude 80 is the last stable value before failure at 120.

Example 2:

Input: altitudes = [30,60], stable = [false,false]
Output: -1
Explanation: All tested altitudes fail, so no safe flight ceiling exists.

Example 3:

Input: altitudes = [], stable = []
Output: -1
Explanation: Without test data, no safe altitude can be confirmed.

00:00
Loading editor...
Test Results

Run your code to see test results

Click the Submit button to execute your solution

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.