Created
August 10, 2014 13:01
-
-
Save mailpraveens/cd05aecf6f217591391c to your computer and use it in GitHub Desktop.
AugustChallenge from hacker rank http://www.hackerearth.com/august-easy-challenge/algorithm/criminals-little-deepu-and-little-kuldeep/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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