Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
#include <iostream>
#include <algorithm>
int main(){
long count[4] = {0};
long n; scanf("%ld", &n);
for(long p = 0; p < n; p++){int temp; scanf("%d", &temp); ++count[temp];}
std::sort(count, count + 4);
printf("%ld\n", count[1] + count[2]);
return 0;
}
Copy The Code &
Try With Live Editor
Input
9
1 3 2 2 2 1 1 2 3
1 3 2 2 2 1 1 2 3
Output
5
Demonstration
Codeforces Solution-A. 123-sequence-Solution in C, C++, Java, Python