Sample ratio mismatch detection

Write codeMedium15 minMeta and Microsoft style

Your task

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].

Examples

srm_flags(counts: list[int], expected_pct: list[int], tol_pct: int) -> list[int]
Example 1
Inputsrm_flags([560, 440], [50, 50], 2)
Output[0, 1]