fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int f_op=1e9;
  4. int minOp(int arr[],int n){
  5. for(int i=0;i<n;i++){
  6. int op=0;
  7. for(int j=0;j<n;j++){
  8. if(arr[i]!=arr[j]){
  9. op++;
  10. }
  11. }
  12. f_op=min(f_op,op);
  13. }
  14. return f_op;
  15. }
  16. int main() {
  17. // your code goes here
  18. int n;
  19. cin>>n;
  20. int arr[n];
  21. for(int i=0;i<n;i++){
  22. cin>>arr[i];
  23. }
  24. cout<<"The minimum operation is:"<<minOp(arr,n);
  25. return 0;
  26. }
Success #stdin #stdout 0s 5312KB
stdin
4
1 2 3 4
stdout
The minimum operation is:3