Code Room
CodingMediumcod-g1361
Subject Ab test mathLevel Entry–Mid~15 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

Before reading any experiment result, a healthy A/B pipeline checks for sample-ratio mismatch: did each variant actually receive its intended share of traffic? Given counts (observed visitors per variant), expected_pct (intended percentage per variant, same length), and an integer tolerance tol_pct, let total be the sum of counts. Variant i is flagged when |100 * counts[i] - expected_pct[i] * total| > tol_pct * total, using exact integer arithmetic. Return the flagged indices in increasing order. If total is 0, return an empty list. Example: counts = [560, 440], expected_pct = [50, 50], tol_pct = 2 returns [0, 1].

Implement
srm_flags(counts: list[int], expected_pct: list[int], tol_pct: int) → list[int]
Examples
in[[560,440],[50,50],2]out[0,1]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.