Dsa
Arrays
Medium
Unique Difference Sequences
Given an array of integers, find all unique absolute differences between all pairs of elements. Return the results as a sorted list.
Input:
- The first line contains an integer n (1 <= n <= 100) — the size of the array.
- The second line contains n space-separated integers, the elements of the array.
Output:
- Print the unique absolute differences in ascending order, separated by space.
Example:
Input:
5
1 2 3 4 5
Output:
1 2 3 4
Key concepts
arraysunique elements
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now