0%

HackerRank Warm-up 1.Sales by Match, in C++

題目連結:Sales by Match | HackerRank

因應HackerRank系統,而分享 Coding 核心部分

1
2
3
4
5
6
7
8
9
10
11
int sockMerchant(int n, vector<int> ar) {
int ct[105]{0};
for(auto a:ar){
ct[a]++;
}
int ans=0;
for(int i=0;i<105;i++){
ans+=ct[i]/2;
}
return ans;
}