Widest Gap
Sort the values; print the largest difference between consecutive sorted values (0 when N = 1).
Input: the first line has N; the second line has N integers.
Output: the maximum adjacent gap after sorting.
Constraints:
- 1 ≤ N ≤ 105
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
4 1 7 3 10
Output 1
4
Input 2
1 5
Output 2
0
Discussion (opens after you solve — no spoilers before)
No comments yet.