The Cricket World Cup 2015 is nearing and it will be held in Australia and New Zealand. The organizing committee is planning to give a welcome gift to each team member. After careful thought and planning, they have decided on Matryoshka dolls.
A Matryoshka doll refers to a set of wooden dolls of strictly decreasing size, placed one inside the other. Any doll can contain only one doll directly inside it.
Given the sizes of N dolls, output "YES" if it is possible to nest them all and have one doll on the outside and "NO" otherwise.
The input starts with T denoting the number of test cases. For each test case, the first line contains N, which is the total number of dolls.
The second line contains N space separated integers denoting the size of the dolls.
Print “YES” if the dolls can be nested inside each other and “NO” otherwise. (quotes for clarity)
1 <= T <= 100
1 <= N <= 100
1 <= doll size <= 1000
Sample Input -
3 1 1
10 2 5 3
Sample Output -
For the first case, there are 2 dolls of size 1 and hence cannot be nested inside each other.
For the second case, the doll with size 1 can be put inside the doll with size 2.
|Tags||amr14ros, cakewalk, murdocc007, sorting|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.