Code RoomProbe request k-th arrival
MediumPrep Room Coding #4861

Probe request k-th arrival

CodingAlgorithms & data structuresMid–Senior~25 min

A synthetic monitoring service runs a set of probes against one endpoint. Probe i sends its first request at second first_tick[i] and repeats every interval[i] seconds after that, forever. Every request lands on one shared timeline, and two probes that fire in the same second contribute two separate requests. The capacity team needs to know when the k-th request of the whole run happens, counting from the very first one. Return the second at which the k-th request is sent, with k counted from 1. Return -1 when there are no probes at all, since no request is ever sent. first_tick holds non-negative seconds, every interval is at least 1, the two lists have the same length, and k is at least 1.

Implement
kth_probe_tick(first_tick: list[int], interval: list[int], k: int) → int
Examples
in[[0,0],[2,3],5]out4
in[[5],[10],3]out25
in[[0,0,0],[5,5,5],4]out5
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 25 min
InputExpectedGot
[[0,0],[2,3],5]4not run yetsample
[[5],[10],3]25not run yetsample
[[0,0,0],[5,5,5],4]5not run yetsample