BudiBadu Logo
00:00

Lantern Stage Volume Check

Binary Search Easy 7 views

During rehearsal, lantern crews record cumulative volume after each stage of the performance. When a director wants to know at what stage the music reaches a requested intensity, the crew should respond instantly rather than replay the entire track. The cumulative volume readings grow monotonically, so the team seeks a fast lookup for each request made during the planning session.

You receive the cumulative volume list (strictly increasing or flat) and several requested thresholds. For each threshold, report the 1-based index of the earliest stage whose cumulative volume meets or exceeds the request; return -1 if no stage is loud enough. Implement the lookup with binary search per query and avoid modifying the volume list. This quick answer lets the director adjust lighting accents, cue pyrotechnics, and balance the evening's temperature of sound.

Example 1:

Input: volumes = [5,9,15,20], requests = [1,15,25]
Output: [1,3,-1]
Explanation: Stage 1 meets 1, stage 3 reaches 15, no stage hits 25.

Example 2:

Input: volumes = [4,4,10], requests = [4,5]
Output: [1,3]
Explanation: The first stage already has 4; stage 3 is the first to meet 5.

Example 3:

Input: volumes = [], requests = [3]
Output: [-1]
Explanation: Without data, no request can be satisfied.

Related Problems

No related problems found

Comments (0)

Join the Discussion

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

BudiBadu Logo

Lantern Stage Volume Check

Binary Search Easy 7 views

During rehearsal, lantern crews record cumulative volume after each stage of the performance. When a director wants to know at what stage the music reaches a requested intensity, the crew should respond instantly rather than replay the entire track. The cumulative volume readings grow monotonically, so the team seeks a fast lookup for each request made during the planning session.

You receive the cumulative volume list (strictly increasing or flat) and several requested thresholds. For each threshold, report the 1-based index of the earliest stage whose cumulative volume meets or exceeds the request; return -1 if no stage is loud enough. Implement the lookup with binary search per query and avoid modifying the volume list. This quick answer lets the director adjust lighting accents, cue pyrotechnics, and balance the evening's temperature of sound.

Example 1:

Input: volumes = [5,9,15,20], requests = [1,15,25]
Output: [1,3,-1]
Explanation: Stage 1 meets 1, stage 3 reaches 15, no stage hits 25.

Example 2:

Input: volumes = [4,4,10], requests = [4,5]
Output: [1,3]
Explanation: The first stage already has 4; stage 3 is the first to meet 5.

Example 3:

Input: volumes = [], requests = [3]
Output: [-1]
Explanation: Without data, no request can be satisfied.

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.