โ† SAP questions

Distinct pairs with difference K

Filed under SAP

Given an array of integers and an integer K, count the number of distinct valid pairs (i, j) such that the absolute difference between nums[i] and nums[j] is equal to K.

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.