Check Arithmetic Progression
Submissions: 1056   Accuracy:

38.54%

  Difficulty: Basic   Marks: 1

Given an array of N integers. Write a program to check whether an arithmetic progression can be formed using all the given elements. If possible print “YES”, else print “NO”.

Input:
First line of input contains a single integer T which denotes the number of test cases. Then T test cases follows. First line of each test case contains a single integer N which denotes number of elements in the array. Second line of each test case contains N space separated integers which denotes elements of the array.

Output:
For each test case, print "YES" without quotes if an arithmetic progression can be formed using all the given elements, else print "NO" without quotes.

Constraints:
1<=T<=100
1<=N<=105
1<=Arr[i]<=105

Example:
Input:

2
4
0 12 4 8
4
12 40 11 20
Output:
YES
NO

 

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Harsh Agarwal
Author: harsh.agarwal0


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.