Skip to content

Instantly share code, notes, and snippets.

@mailpraveens
Created August 10, 2014 13:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mailpraveens/cd05aecf6f217591391c to your computer and use it in GitHub Desktop.
Save mailpraveens/cd05aecf6f217591391c to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
#include <stdlib.h> /* qsort */
int compare (const void * a, const void * b) {
return ( *(int*)a - *(int*)b );
}
int main4()
{
int testcases = 0;
cin >> testcases;
while(testcases > 0) {
int n;
cin >> n;
int a[n];
for(int i = 0; i < n; i++){
cin >> a[i];
}
qsort(a, n, sizeof(int), compare);
int i = 0;
int j = i;
int total = n;
for( i = 0 ; i < n-1 ; i++){
if(a[i] < a[i+1]){
total = total - 1;
}
}
cout << total << endl;
testcases--;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment