This is a verified interview question from Lseg---london-stock-exchange. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "SLA Breach Window Detector - LSEG London Stock Exchange Online Assessment RNS Institute" covers key patterns like Arrays.
"Write `solution(metrics, k, error_threshold, latency_threshold)`. Given monitoring samples `[requests, errors, p95_latency]` (one per minute, chronological), a window size k, error-rate threshold, and latency threshold, return the **starting indices** of all contiguous windows of exactly k samples that breach the SLA. For a window: `total_requests`/`total_errors` = sums over window; `max_latency` = max p95_latency in window. `error_rate = total_errors/total_requests` (0 if total_requests = 0). Window breaches iff `error_rate > error_threshold` OR `max_latency > latency_threshold` (both strict; exact ties are NOT breaches). If `length(metrics) < k`, return empty list. **Constraints**: 0 ≤ length(metrics) ≤ 200,000; 1 ≤ k ≤ 200,000; requests/errors/p95_latency integers with 0 ≤ requests ≤ 1,000,000, 0 ≤ errors ≤ requests, 0 ≤ p95_latency ≤ 1,000,000; thresholds ≥ 0 with ≤4 decimal digits. Must run in ~O(length(metrics)) — an O(length × k) solution will TLE on hidden large inputs. Compare using genuine double division `total_errors / total_requests > error_threshold`, not the rearranged multiplication form (which can misjudge exact ties due to floating-point rounding). **Example 1** ``` metrics = [[100,40,100],[100,0,100],[100,0,100],[100,0,100],[100,0,400],[100,0,100]] k = 3, error_threshold = 0.05, latency_threshold = 300 ``` Output: `[0, 2, 3]` **Example 2** ``` metrics = [[0,0,100],[0,0,100],[4,1,500],[4,1,500]] k = 2, error_threshold = 0.25, latency_threshold = 500 ``` Output: `[]` (both computed values are exactly equal to thresholds — not breaches) **Example 3** ``` metrics = [[100,10,100],[100,10,100]] k = 2, error_threshold = 0.05, latency_threshold = 500 ``` Output: `[0]` ---"
Join thousands of developers practicing for Lseg---london-stock-exchange.