InterviewDB Question

Breakdown Point: Find the Earliest Index Where a Running Metric Drops Below a Threshold

Question Details

Problem

You have a stream of time-series values. Compute the running average up to each index and find the first index where that running average falls below a given threshold.

Return the index, or -1 if it never does.

python
def breakdown_point(values: list[float], threshold: float) -> int:
    pass

Example:

values    = [5.0, 4.0, 6.0, 1.0, 2.0]
threshold = 3.5
# running avgs: 5.0, 4.5, 5.0, 4.0, 3.6
-> -1   # never drops below 3.5... wait: 3.6 > 3.5; correct: -1

values    = [5.0, 4.0, 6.0, 1.0, 1.0]
threshold = 3.5
# running avgs: 5.0, 4.5, 5.0, 4.0, 3.4
-> 4

Follow-ups

  1. Can you find the breakdown point in a single pass with O(1) extra space? Show the approach.
  2. How would you find the breakdown point for a rolling window average (e.g., last 5 values) instead of a cumulative average?
  3. If the values represent reliability scores for a distributed system, what does this metric signify operationally?
  4. How would you extend this to detect when the running average crosses the threshold in either direction (both up and down crossings)?

Full Details

Problem

You have a stream of time-series values. Compute the running average up to each index and find the first index where that running average falls below a given threshold.

Return the index, or -1 if it never does.

python
def breakdown_point(values: list[float], threshold: float) -> int:
    pass

Example:

values    = [5.0, 4.0, 6.0, 1.0, 2.0]
threshold = 3.5
# running avgs: 5.0, 4.5, 5.0, 4.0, 3.6
-> -1   # never drops below 3.5... wait: 3.6 > 3.5; correct: -1

values    = [5.0, 4.0, 6.0, 1.0, 1.0]
threshold = 3.5
# running avgs: 5.0, 4.5, 5.0, 4.0, 3.4
-> 4

Follow-ups

  1. Can you find the breakdown point in a single pass with O(1) extra space? Show the approach.
  2. How would you find the breakdown point for a rolling window average (e.g., last 5 values) instead of a cumulative average?
  3. If the values represent reliability scores for a distributed system, what does this metric signify operationally?
  4. How would you extend this to detect when the running average crosses the threshold in either direction (both up and down crossings)?

About This Question

This is a reported interview question from a nuro interview during the phone round.

It covers the following topics: System Design, Coding, Phone, Onsite .