## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Sort Zero Codeforces Solution

C. Sort Zero
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an array of

$n$ positive integers ${a}_{1},{a}_{2},\dots ,{a}_{n}$.

In one operation you do the following:

1. Choose any integer $x$.
2. For all $i$ such that ${a}_{i}=x$, do ${a}_{i}:=0$ (assign $0$ to ${a}_{i}$).

Find the minimum number of operations required to sort the array in non-decreasing order.

Input

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\le t\le {10}^{4}$).

Solution Click Below:-  👉
👇👇👇👇👇

Description of the test cases follows.

The first line of each test case contains a single integer $n$ ($1\le n\le {10}^{5}$).

The second line of each test case contains $n$ positive integers ${a}_{1},{a}_{2},\dots ,{a}_{n}$ ($1\le {a}_{i}\le n$).

It is guaranteed that the sum of $n$ over all test cases does not exceed ${10}^{5}$.

Output

For each test case print one integer — the minimum number of operations required to sort the array in non-decreasing order.