Distinct Adjacent Element
Submissions: 1104   Accuracy:

28.36%

  Difficulty: Basic   Marks: 1

Given an array whether it is possible to obtain an array having distinct neighboring elements by swapping two neighboring array elements.

Input:
First line consists of T test cases. First line of every test case consists of an integer N, denoting number of elements in array. Second line of every test case consists of elements of array.

Output:
Single line output, print YES if possible else NO.

Constraints:
1<=T<=200
1<=N<=10^4

Example:
Input:

2
4
7 7 7 7
3
1 1 2
Output:
NO
YES

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

Contributor: Saksham Raj Seth
Author: saksham seth


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.