Algorithm · C3.ai · Easy
You are given a list of integers nums and an integer target. Count the pairs (x, y) taken from the list whose two values differ by exactly target in absolute terms, that is, pairs for which $$ x - y = target$$. Return this count as an integer. You may rely on every element of nums being distinct. Example 1: Example 2: Example 3: Constraints: $$1 \le nums.length \le 10^4$$ $$-10^4 \le nums[i] \le 10^4$$ $$-10^4 \le target \le 10^4$$ All elements of nums are distinct.