All Pairs?


Submit solution

Points: 4 (partial)
Time limit: 5.0s
Memory limit: 256M

Author:
Problem type

Alice and Bob are classmates and are preparing for JEE Advanced. Alice challenged Bob by giving him a problem to solve. Bob was given N number of integers. He has to pick any two integers from the given N integers such that the absolute difference between the two picked integers is maximum possible.

As Bob is struggling to solve the challenge, he seeks your help to do so. Can you help him?

CONSTRAINTS

  • 1 ≤ T ≤ 10
  • 2 ≤ N ≤ 10^5
  • -10^3 ≤ each element of the given list ≤ 10^3

INPUT:

  • The first line contains an integer T denoting the number of test case(s).
  • Each test case consists of two lines.
  • The first line of each test case contains a single integer denoting N.
  • The second line of each test case contains N integers separated by a space.

OUTPUT:

  • For each test case output the maximum possible absolute difference. (answer each testcase in each line)

Sample Input:

1
2
1 1

Sample Output:

0

Comments