Sales by Match
https://www.hackerrank.com/challenges/sock-merchant/problem
int sockMerchant(int n, int ar_count, int* c) {
int count = 0;
for(int i=0; i<n; i++){
if(c[i]!=0){
for(int j=i+1; j<n; j++){
if(c[i]==c[j]){
count++;
c[j]=0;
break;
}
}
}
}
return count;
}
Comments
Post a Comment