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

Question

Your experimentation platform sizes tests from a precomputed lookup table instead of a stats library. Each table row is [min_baseline_bps, max_baseline_bps, min_mde_bps, sample_size]: the row applies when the baseline conversion rate satisfies min_baseline_bps <= baseline_bps <= max_baseline_bps and the effect you want to detect satisfies mde_bps >= min_mde_bps. Given the table plus the experiment's baseline_bps and mde_bps, return the smallest sample_size among all applicable rows, or -1 when no row applies. Example: table = [[100, 500, 100, 20000], [100, 500, 200, 8000], [501, 1000, 100, 12000]], baseline_bps = 300, mde_bps = 250 returns 8000.

Implement
required_sample(table: list[list[int]], baseline_bps: int, mde_bps: int) → int
Examples
in[[[100,500,100,20000],[100,500,200,8000],[501,1000,100,12000]],300,250]out8000
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.