Hey @S4G4R you are right, the way you are handling **distance > k** is wrong.

**How do you decide which pointer to move?**

Let’s solve much simpler problem, Assume we are working with two sorted arrays and our goal is to find the first pair whose difference <= k.

K = 3

Array A = [9, 15, 19]

Array B = [20, 21]

**Output : 19 and 20**

Let’s say *i and j* are two pointers on A and B arrays respectively on index 0.

Now A[i] + A[j] = 29 and 29 is greater than K(3) so which pointer should we move to reduce the difference and find that first pair whose diff <= k.

We should always move the pointer which is pointing to smaller value so that our difference will reduce. In this case we should move *i* pointer.

Got the cue? Coming back to original question you should move the pointer based on the values of registration numbers of Good and Bad cars.

Happy Coding