Code RoomCount builds in range
EasyPrep Room Coding #4806

Count builds in range

CodingAlgorithms & data structuresEntry–Mid~16 min

A deploy log records every rollout to production in build order, so builds is sorted ascending and holds nonnegative build numbers. One build number can appear several times, because a build reaches one region at a time and each region logs its own record. A release report asks the log a batch of range questions. lows and highs have the same length, and query k asks how many records carry a build number strictly between lows[k] and highs[k]: above the low and below the high, with both endpoints excluded, so a record on either endpoint is not counted. Return one count per query, in the order asked. A query whose high is at or below its low describes nothing and answers 0, and an empty log answers 0 for every query. When no queries are asked, return an empty list. The log holds years of rollouts, so halve it per query rather than counting records one at a time.

Implement
count_deploys_between(builds: list[int], lows: list[int], highs: list[int]) → list[int]
Examples
in[[1041,1041,1055,1055,1055,1090,1104],[1041,1040,1041],[1090,1042,1055]]out[3,2,0]
in[[10,10,12,15,15,15,20,31],[9,10,15,30,0],[11,20,15,40,100]]out[2,4,0,1,8]
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 16 min
InputExpectedGot
[[1041,1041,1055,1055,1055,1090,1104],[1041,1040,1041],[1090,1042,1055]][3,2,0]not run yetsample
[[10,10,12,15,15,15,20,31],[9,10,15,30,0],[11,20,15,40,100]][2,4,0,1,8]not run yetsample