← SAP questions

Count all distinct pairs with difference equal to K

Filed under SAP

Given an array of integers and an integer $K$, count the number of distinct pairs $(a, b)$ such that the absolute difference between $a$ and $b$ is exactly $K$. A pair $(a, b)$ is considered the same…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related SAP questions

Collected from public candidate posts and coding forums. Updated Nov 2026.