-
Notifications
You must be signed in to change notification settings - Fork 2
/
EQDIFFER.cpp
45 lines (45 loc) · 1021 Bytes
/
EQDIFFER.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
vector<int> v1;
map<int, int> frequency;
int n, element, frq = 0,result;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> element;
v1.push_back(element);
frequency[element]++;
frq = max(frq, frequency[element]);
}
map<int, int>::iterator i1;
// for (i1 = frequency.begin(); i1 != frequency.end(); i1++)
// {
// frq = max(frq, i1->second);
// }
result = 0;
if (v1.size() > 2)
{
if (frq == 1)
{
// cout << n - 2 << endl;
result = n - 2;
}
else
{
// cout << n - frq << endl;
result = n - frq;
}
}
else
{
// cout << 0 << endl;
}
cout << result << endl;
}
}