Problem
You are given a list of size .You have to make a new list such that is equal to the number of elements than in the list .
Print the .
Input
The first line consists of , denoting the number of test cases.
First line of each test case consists of one integer denoting , where is the size of the list given to you.
Second line of each test case contains the list given to you containing elements.
Output
For each test case print the list in a single line and the elements of the list should be separated by .
Print the answer to test case in a .
Constraints
- , where is the number of test cases.
- , where is the number of elements in the list.
- ,where is the element in the list given to you.
Subtasks
- : All the elements in the list given to you are distinct.
- : Original constraints: Elements can be repeated in the list.
Sample 1:
2 4 1 2 4 4 5 1 2 2 2 2
3 2 0 0 4 0 0 0 0
Explanation:
The explanation for test case 1 of sample input :
The first element in the new list is 3 since the first element in the previous list was 1, and there are three elements which are strictly greater than 1, that is 2, 4 and 4.
The second element in the new list is 2 since the second element in the previous list was 2, and there are two elements which are strictly greater than 2, that is 4 and 4.
The third and fourth element in the new list is 0 since third and fourth element in the previous list was 4 and there are no elements which are strictly greater than them.
Program :
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sr=new Scanner(System.in);
int t=sr.nextInt();
while(t-->0)
{
int n=sr.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++)
{
a[i]=sr.nextInt();
}
for(int i=0;i<n;i++)
{
int c=0;
for(int j=i+1;j<n;j++)
{
if(a[i]<a[j])
c++;
}
System.out.print(c+" ");
}
System.out.println();
}
}
}
0 Comments