Code RoomSensor pair sum count
MediumPrep Room Coding #609

Sensor pair sum count

CodingAlgorithms & data structuresEntry–Mid~14 min

Two calibration sensors each output a strictly increasing list of readings. A pairing test asks: how many ways can you pick one reading from sensor a and one from sensor b so that they add up exactly to target? Given a and b (each strictly increasing, no duplicates within a list) and the target, return the count. Walk a forward and b backward in one combined pass. Example: a = [1, 3, 5], b = [2, 4, 6], target = 7 gives 3 (1+6, 3+4, 5+2).

Implement
count_matching_pairs(a: list[int], b: list[int], target: int) → int
Examples
in[[1,3,5],[2,4,6],7]out3
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
[[1,3,5],[2,4,6],7]3not run yetsample