Increasing (Codeforces 1742B)
Tags: Greedy, sortings

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).

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]$$$.

Sample Inputs:
3
4
1 1 1 1
5
8 7 1 3 4
1
5

Sample Outputs:
NO
YES
YES

Solution (Python):
def solve():
    n = int(input())
    a = []
    s = input()
    ss = s.split(' ')
    for x in ss:
        a.append(int(x))
    b = []
    for x in a:
        b.append(x)
    b = sorted(b)
    for i in range(n - 1):
        if b[i] >= b[i + 1]:
            print('NO')
            return
    print('YES')
t = int(input())
for x in range(t):
    solve()

Solution (Python):
for i in range(int(input())):
    n = int(input())
    l = list(map(int, input().split()))
    lt = l.sort()
    c = 0
    for i in l:
        if l.count(i) > 1:
            c = 1
        else:
            continue
    if c == 1:
        print('NO')
    else:
        print('YES')

Solution (Python):
t = int(input())
for _ in range(t):
    n = int(input())
    nums = list(map(int, input().split()))
    if len(nums) > 1:
        if len(set(nums)) < n:
            print('NO')
        else:
            print('YES')
    else:
        print('YES')