Short Problem Definition:
Given N integers, count the number of pairs of integers whose difference is K.
time complexity is O(N*log(N))
space complexity is O(N)
The solution is pretty straight-forward, just read the code :). The runtime complexity is calculated with log(N) access times for tree-based sets (not the case in Python).