GUPTA MECHANICAL

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

Tuesday 16 August 2022

[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 a1,a2,,an.

In one operation you do the following:

  1. Choose any integer x.
  2. For all i such that ai=x, do ai:=0 (assign 0 to ai).

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 (1t104).

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

 Description of the test cases follows.

The first line of each test case contains a single integer n (1n105).

The second line of each test case contains n positive integers a1,a2,,an (1ain).

It is guaranteed that the sum of n over all test cases does not exceed 105.

Output

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

No comments:

Post a Comment