Code RoomSample size lookup
MediumPrep Room Coding #554

Sample size lookup

CodingAlgorithms & data structuresEntry–Mid~14 min

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.

0:00 of about 14 min
InputExpectedGot
[[[100,500,100,20000],[100,500,200,8000],[501,1000,100,12000]],300,250]8000not run yetsample