Code Room
CodingMediumcod-g1413
Subject Two pointersLevel Entry–Mid~14 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.