You are given an array $a$ of $n$ positive integers. Determine if, by rearranging the elements, you can make the array strictly increasing. In other words, determine if it is possible to rearrange the elements such that $a_1 < a_2 < \dots < a_n$ holds.


-----Input-----

The first line contains a single integer $t$ ($1 \leq t \leq 100$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($1 \leq n \leq 100$) — the length of the array.

The second line of each test case contains $n$ integers $a_i$ ($1 \leq a_i \leq 10^9$) — the elements of the array.


-----Output-----

For each test case, output "YES" (without quotes) if the array satisfies the condition, and "NO" (without quotes) otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).


-----Examples-----

Input
3
4
1 1 1 1
5
8 7 1 3 4
1
5
Output
NO
YES
YES


-----Note-----

In the first test case any rearrangement will keep the array $[1,1,1,1]$, which is not strictly increasing.

In the second test case, you can make the array $[1,3,4,7,8]$.

Difficulty: EASY
Tags: Sorting

Implementation

Greedy algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) < len(a):
		print('NO')
	else:
		print('YES')


try:
	for _ in range(int(input())):
		n = int(input())
		lst = list(map(int, input().split()))
		if len(lst) == len(set(lst)):
			print('YES')
		else:
			print('NO')
except:
	pass


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if len(set(arr)) == n or n == 1:
		print('YES')
	else:
		print('NO')


for z in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	D = {}
	for i in a:
		if i in D:
			D[i] += 1
		else:
			D[i] = 1
	flag = 0
	for i in D:
		if D[i] > 1:
			flag = 1
			break
	if flag == 0:
		print('YES')
	elif flag == 1:
		print('NO')


a = int(input())
sp = []
for i in range(a):
	n = 0
	h = int(input())
	b = list(map(int, input().split()))
	for y in b:
		if b.count(y) > 1:
			sp.append('NO')
			break
		else:
			n += 1
	if n == h:
		sp.append('YES')
for j in sp:
	print(j)


for _ in range(int(input())):
	length = int(input())
	massiv = input().split()
	massiv_set = set(massiv)
	if len(massiv_set) == length:
		print('YES')
	else:
		print('NO')


t = int(input())
for p in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	if n == 1:
		print('YES')
	else:
		x.sort()
		flag = 0
		for i in range(0, n - 1):
			if x[i] == x[i + 1]:
				flag = 1
				break
			else:
				continue
		if flag == 0:
			print('YES')
		else:
			print('NO')


z = int(input())
for i in range(z):
	s = int(input())
	temp = list(map(int, input().split()))
	new = set(temp)
	if len(new) != len(temp):
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	s = set(l)
	if len(s) == len(l):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	fl = 0
	for i in range(n - 1):
		if arr[i] == arr[i + 1]:
			print('NO')
			fl = 1
			break
	if fl == 0:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = set(map(int, input().split()))
	k = len(arr)
	if n == k:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	input()
	arr = [int(x) for x in input().strip().split()]
	arr = sorted(arr)
	if len(arr) == len(set(arr)):
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	v = int(input())
	st = list(map(int, input().split()))
	if len(st) != len(set(st)):
		print('NO')
	elif len(st) == len(set(st)):
		print('YES')
	t -= 1


r = int(input())
while r > 0:
	a = int(input())
	s = list(map(int, input().split()))
	if len(s) != len(set(s)):
		print('NO')
	elif len(s) == len(set(s)):
		print('YES')
	r -= 1


g = int(input())
while g > 0:
	c = int(input())
	lb = list(map(int, input().split()))
	if len(lb) != len(set(lb)):
		print('NO')
	elif len(lb) == len(set(lb)):
		print('YES')
	g -= 1


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	s = set()
	f = 0
	for i in range(n):
		if a[i] in s:
			f = 1
			print('NO')
			break
		s.add(a[i])
	if f == 0:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	k = len(s)
	if n == k:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	check = 1
	for i in range(1, n):
		if s[i] <= s[i - 1]:
			check = 0
	if check:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	if len(set(a)) == n:
		print('YES')
	else:
		print('NO')


def increase(a, n):
	if len(a) == 1:
		return 'YES'
	else:
		for i in range(n - 1):
			if a[i] == a[i + 1]:
				return 'NO'
	return 'YES'
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(increase(a, n))


t = int(input())
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	c = 0
	for i in range(len(a)):
		if a[i] > a[i - 1]:
			c = c + 1
	if c == len(a) - 1:
		print('YES')
	else:
		print('NO')


for XD in range(int(input())):
	N = int(input())
	l = list(map(int, input().split()))
	if len(set(l)) == len(l):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	temp = ['a']
	count = 0
	for i in lis:
		if i in temp:
			count = 1
			print('NO')
			break
		temp.append(i)
	if count == 0:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = [x for x in input().split()]
	s = set()
	for val in a:
		s.add(val)
	if n == len(s):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	ar = [int(x) for x in input().split()]
	s = set(ar)
	if len(s) == n:
		print('YES')
	else:
		print('NO')


for t in [*open(0)][2::2]:
	print('YNEOS'[len((a := t.split())) > len({*a})::2])


t = int(input())
f = 0
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if len(arr) != 1:
		for j in range(0, len(arr) - 1):
			if arr[j] == arr[j + 1]:
				f = 1
				break
	if f == 1:
		print('NO')
	else:
		print('YES')
	arr = []
	f = 0


n = int(input())
for i in range(n):
	k = int(input())
	c = set(map(int, input().split()))
	if len(c) == k:
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	sorted_arr = sorted(arr)
	count = 0
	for i in range(n - 1):
		temp = sorted_arr[i]
		if sorted_arr[i + 1] == temp:
			count += 1
	if count >= 1:
		print('NO')
	else:
		print('YES')
tt = int(input())
for i in range(tt):
	main()


x = int(input())
ch = []
for i in range(0, x):
	o = input()
	arr = list(map(int, input().split()))
	l_arr = len(arr)
	myset = set(arr)
	l_myset = len(myset)
	if l_myset == l_arr:
		print('YES')
	else:
		print('NO')


def evaluar(lista):
	for i in range(1, len(lista)):
		if lista[i] == lista[i - 1]:
			return False
	return True
t = int(input())
while t > 0:
	n = int(input())
	lista = [int(i) for i in input().split()]
	lista.sort()
	if evaluar(lista):
		print('YES')
	else:
		print('NO')
	t -= 1


for i in range(int(input())):
	x = int(input())
	ar = list(map(int, input().split()))
	s = set(ar)
	if len(ar) == len(s):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	x.sort()
	f = 0
	for i in range(len(x) - 1):
		if x[i] >= x[i + 1]:
			f = 1
			break
	if f == 0:
		print('YES')
	else:
		print('NO')


import sys
lines = list(map(str.strip, sys.stdin.readlines()))
for line in lines[2::2]:
	nums = list(map(int, line.split(' ')))
	nums.sort()
	bad = False
	for i in range(len(nums) - 1):
		if nums[i] >= nums[i + 1]:
			bad = True
			break
	print('NO' if bad else 'YES')


for aSDASFAF in range(int(input())):
	n = int(input())
	items = list(map(int, input().split()))
	count = set()
	for i in items:
		if i in count:
			print('NO')
			break
		count.add(i)
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	answer = 'YES'
	for i in range(1, n):
		if a[i] > a[i - 1]:
			continue
		else:
			answer = 'NO'
			break
	print(answer)


x = int(input())

def do(has):
	b = sorted(has)
	return len(set(has)) == len(has)
for _ in range(x):
	a = int(input())
	lis = list(map(int, input().split()))
	print('YES' if do(lis) else 'NO')


t = int(input())

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	hash_map = {}
	for i in range(n):
		if arr[i] not in hash_map:
			hash_map[arr[i]] = 1
		else:
			print('NO')
			return
	print('YES')
while t:
	solve()
	t -= 1


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	d = {}
	f = True
	for i in arr:
		if d.get(i) is not None:
			f = False
			break
		d[i] = 1
	if f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	if len(arr) == len(set(arr)):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	arr = sorted(map(int, input().split()))
	for i in range(1, n):
		if arr[i - 1] == arr[i]:
			print('NO')
			break
	else:
		print('YES')


for _ in range(int(input())):
	x = int(input())
	y = list(map(int, input().split()))
	z = list(sorted(y))
	for i in range(1, x):
		if z[i] == z[i - 1]:
			print('NO')
			break
	else:
		print('YES')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	nums.sort()
	flag = True
	for i in range(n - 1):
		if nums[i] == nums[i + 1]:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	a = input().split()
	bo = True
	for i in range(n):
		c = a.count(a[i])
		if c >= 2:
			bo = False
			break
	if bo:
		print('YES')
	else:
		print('NO')
	t = t - 1


o = int(input())
for i in range(o):
	l = int(input())
	a = list(map(int, input().split()))
	z = set(a)
	if len(z) == len(a):
		print('YES')
	else:
		print('NO')


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = [int(i) for i in input().split()]
		a.sort()
		fg = 0
		for i in range(1, n):
			if a[i] - a[i - 1] <= 0:
				fg = 1
				print('NO')
				break
		if fg == 0:
			print('YES')
main()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	s1 = set(arr)
	if len(arr) == len(s1):
		print('YES')
	else:
		print('NO')


for i in [0] * int(input()):
	input()
	a = list(map(int, input().split()))
	b = set(a)
	print(len(a) == len(b) and 'YES' or 'NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	r = sorted(l)
	flag = True
	for i in range(len(r) - 1):
		if r[i] >= r[i + 1]:
			flag = False
			break
	if flag == True:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	col_elem = int(input())
	line_num = list(map(int, input().split()))
	mnoj = set()
	for elem in line_num:
		mnoj.add(elem)
	if len(line_num) == len(mnoj):
		print('YES')
	else:
		print('NO')


cases = int(input())
for i in range(cases):
	le = int(input())
	ar = [int(x) for x in input().split()]

	def inc(ar):
		temp = []
		for i in ar:
			if i not in temp:
				temp.append(i)
			else:
				return 'NO'
		return 'YES'
	print(inc(ar))


p = int(input())
for i in range(p):
	k = int(input())
	u = list(map(int, input().split()))
	h = sorted(u)
	l = 0
	for j in range(len(h)):
		if h[j - 1] < h[j]:
			l = l + 1
	if len(h) - 1 == l:
		print('YES')
	else:
		print('NO')


ans = []
for i in range(int(input())):
	t = input()
	n = input().split()
	if len(set(n)) == len(n):
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


t = int(input())
for tc in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if len(list(set(l))) == len(l):
		print('YES')
	else:
		print('NO')


numOfCases = int(input())
for test in range(numOfCases):
	arrayLength = int(input())
	array = input().split(' ')
	dic = {}
	yes = True
	for i in range(arrayLength):
		if array[i] not in dic:
			dic[array[i]] = False
		else:
			yes = False
			break
	if yes:
		print('YES')
	else:
		print('NO')


number_1 = int(input())
for i in range(number_1):
	number_2 = int(input())
	a = input().split()
	list_numbers = list(map(int, a))
	visited = set()
	dup = [x for x in list_numbers if x in visited or (visited.add(x) or False)]
	a = []
	if dup == a:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	freq = {}
	for i in A:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	flag = 0
	for i in freq.values():
		if i > 1:
			print('NO')
			flag = 1
			break
	if flag == 0:
		print('YES')


T = int(input())
for _ in range(T):
	N = int(input())
	a = [int(x) for x in input().split()]
	ans = sorted(a)
	res = all((x < y for (x, y) in zip(ans, ans[1:])))
	if str(res) == 'True':
		print('YES')
	else:
		print('NO')


x = int(input())
for i in range(x):
	a = int(input())
	n = input().split()
	if len(n) > len(set(n)):
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	nums = [int(x) for x in input().split()]
	nums2 = set(nums)
	if len(nums) == len(nums2):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = []
	flag = 0
	for i in l:
		if i not in m:
			m.append(i)
		else:
			flag = 1
			break
	if flag == 1:
		print('NO')
	else:
		print('YES')


def test(tc):
	a = []
	for b in tc.split():
		if b in a:
			return 'NO'
		else:
			a.append(b)
	return 'YES'

def t_input():
	x = input()
	y = input()
	return y
tcaseno = int(input())
tcases = []
for i in range(tcaseno):
	tcases.append(t_input())
results = []
for tcase in tcases:
	results.append(test(tcase))
for res in results:
	print(res)


x = int(input())
for i in range(x):
	x1 = int(input())
	x2 = list(map(int, input().split(' ')))
	x2.sort()
	a = 0
	ans = True
	while a < len(x2) - 1 and ans:
		if x2[a] == x2[a + 1]:
			ans = False
		else:
			a += 1
	if ans == True:
		print('YES')
	else:
		print('NO')


def solution(n, arr):
	arr = sorted(arr)
	for i in range(1, n):
		if arr[i] == arr[i - 1]:
			return 'NO'
	return 'YES'
for i in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split(' ')]
	print(solution(n, arr))


tst = int(input())
for i in range(tst):
	size = int(input())
	arr = list(map(int, input().strip().split()))
	arr.sort()
	count = 0
	for i in range(size - 1):
		if arr[i] == arr[i + 1]:
			count = count + 1
	if count >= 1:
		print('NO')
	else:
		print('YES')


t = int(input())
l = []
for i in range(t):
	a = int(input())
	b = input().split()
	c = list(b)
	for i in range(len(c)):
		c[i] = int(c[i])
	c.sort()
	d = True
	e = 0
	for i in c:
		if i > e:
			e = i
		else:
			d = False
			break
	if d:
		l.append('YES')
	else:
		l.append('NO')
for i in l:
	print(i)


T = int(input())

def main():
	lenArr = input()
	arr = [int(i) for i in input().split()]
	yes = True
	arr.sort()
	for i in range(len(arr) - 1):
		if arr[i] >= arr[i + 1]:
			yes = False
	if yes:
		print('YES')
	else:
		print('NO')
for t in range(T):
	main()


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ok = True
	for i in range(1, n):
		if a[i] == a[i - 1]:
			ok = False
	if ok:
		print('YES')
	else:
		print('NO')
	t -= 1


def INC(y, z):
	z.sort()
	p = 0
	q = 0
	r = 1
	for i in range(y):
		if q < y and r < y:
			if z[q] < z[r]:
				p += 1
			else:
				break
		q += 1
		r += 1
	if p + 1 == y:
		return 'YES'
	else:
		return 'NO'
for _ in range(int(input())):
	y = int(input())
	z = list(map(int, input().split()))
	print(INC(y, z))


for _ in range(int(input())):
	flag = True
	n_ = input()
	n = input().split()
	for i in range(len(n)):
		n[i] = int(n[i])
	n.sort()
	for i in range(1, len(n)):
		if n[i] == n[i - 1]:
			flag = False
	if flag:
		print('YES')
	else:
		print('NO')


def main():
	n = int(input())
	lista = list(map(int, list(input().split())))
	lista.sort()
	for i in range(n - 1):
		if lista[i] < lista[i + 1]:
			pass
		else:
			print('NO')
			return 0
	print('YES')
	return 0
for _ in range(int(input())):
	main()


T = int(input())
for i in range(T):
	N = int(input())
	arr_num = [int(i) for i in input().split()]
	new_arr = set(arr_num)
	if len(new_arr) == N:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	a = int(input())
	b = list(map(int, input().split()))
	c = set(b)
	if len(c) == len(b):
		print('YES')
	else:
		print('NO')


def alg(mass):
	for arr in mass:
		if len(arr) == len(set(arr)):
			print('YES')
		else:
			print('NO')

def parsing():
	n = int(input())
	mass = []
	while n > 0:
		k = int(input())
		st = input().split(' ')
		res = list(map(int, st))
		mass.append(res)
		n -= 1
	return mass
ms = parsing()
alg(ms)