BackmediumUncategorized uncategorized medium

Pairs With Constant Difference Solution

Problem Statement

You are given an array of integers `arr` containing distinct elements. Find all pairs of elements in `arr` that have a difference of 27 and return them as a list of pairs.

Example 1
Input
[1, 28, 3, 30]
Output
[[1, 28], [3, 30]]

Explanation: The pairs (1, 28) and (3, 30) have a difference of 27.

Constraints

  • 1 <= arr.length <= 1000
  • -10000 <= arr[i] <= 10000
  • All elements in the array are distinct
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free