Code RoomExperiment duration
EasyPrep Room Coding #557

Experiment duration

CodingAlgorithms & data structuresEntry–Mid~10 min

A PM asks how long an experiment must run. You need required_per_variant visitors in each of num_variants equally sized groups, and the site delivers daily_visitors eligible visitors per day (all of whom enter the experiment). The experiment runs whole days, so any partial final day rounds up. Compute total = required_per_variant * num_variants and return the smallest whole number of days d with d * daily_visitors >= total, which equals ceil(total / daily_visitors) = (total + daily_visitors - 1) / daily_visitors using integer division. All inputs are non-negative and daily_visitors >= 1. Example: required_per_variant = 5000, num_variants = 2, daily_visitors = 3000 returns 4.

Implement
days_needed(required_per_variant: int, num_variants: int, daily_visitors: int) → int
Examples
in[5000,2,3000]out4
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 10 min
InputExpectedGot
[5000,2,3000]4not run yetsample