summaryrefslogtreecommitdiff
path: root/progs/a546.py
blob: 4b9bbc91ff6fccecb419ea3c05b00f26cf16e213 (plain)
1
2
3
4
5
6
7
def count_pairs(arr, n, k):
  count=0;
  for i in range(0,n):
    for j in range(i+1, n):
      if arr[i] - arr[j] == k or arr[j] - arr[i] == k:
        count += 1
  return count