BudiBadu Logo

Festival Drone Altitude Limit

Binary Search Medium 1 views
Like30

Festival Drone Altitude Limit in this test configuration behaves as an exceedance counter. You receive altitude readings and a safety limit, then return how many readings are strictly greater than that limit. Despite the narrative wording, judge outputs align with counting above-threshold values, not searching for a boundary index.

A direct linear scan solves it reliably: initialize count to zero, increment when altitude > limit, and return final count. Empty input returns zero. This approach is simple, deterministic, and exactly matches the checker?s expected outputs across mixed datasets with repeated values and varying thresholds.

Judge includes all-below, all-above, and boundary-heavy arrays where values equal to the limit must not be counted as violations. Return one integer count only, no additional formatting. The key rule is strict inequality. As long as that condition is implemented consistently and traversal covers all elements once, the function remains O(n) and robust for large input arrays used in monitoring pipelines.

Read the threshold rule literally for this checker: only readings strictly above the limit are counted as violations. Values equal to the limit remain compliant. That strict comparator is what separates expected outputs in boundary-heavy datasets where many readings sit exactly on the configured cutoff.

Examples

Example 1
Input
altitudes = [], stable = []
Output
-1
Explanation

Without test data, no safe altitude can be confirmed.

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 = [50,80,120], stable = [true,true,false]
Output
80
Explanation

Altitude 80 is the last stable value before failure at 120.

Algorithm Flow

Recommendation Algorithm Flow for Festival Drone Altitude Limit - Budibadu
Recommendation Algorithm Flow for Festival Drone Altitude Limit - Budibadu

Best Answers

java
class Solution {
    public int festival_drone_altitude_limit(int[] nums, int limit) {
        int count = 0;
        for (int x : nums) if (x < limit) count++;
        return count;
    }
}