Pairs with a given difference
mediumProblem solving20 XP
nums has different numbers. Return how many pairs of them differ by exactly k (k is more than 0). Use a set to make it fast.
Examples
- Input: nums = [1, 5, 3, 4, 2], k = 2Output: 3
- Input: nums = [1, 10], k = 5Output: 0
Examples use JSON: true/false/null are True/False/None in Python.