3
int minimumOperations(vector<int> &nums) {4
int totalEven = 0, totalOdd = 0;6
unordered_map<int, int> mapEven, mapOdd;8
for (int i = 0; i < nums.size(); i++) {20
int firstEvenCount = 0, firstEven = 0;21
int secondEvenCount = 0, secondEven = 0;23
for (auto it = mapEven.begin(); it != mapEven.end(); it++) {25
int count = it->second;27
if (count >= firstEvenCount) {28
secondEvenCount = firstEvenCount;29
secondEven = firstEven;30
firstEvenCount = count;34
else if (count >= secondEvenCount) {35
secondEvenCount = count;40
int firstOddCount = 0, firstOdd = 0;41
int secondOddCount = 0, secondOdd = 0;43
for (auto it = mapOdd.begin(); it != mapOdd.end(); it++) {45
int count = it->second;47
if (count >= firstOddCount) {48
secondOddCount = firstOddCount;50
firstOddCount = count;54
else if (count >= secondOddCount) {55
secondOddCount = count;60
int operationsEven = 0, operationsOdd = 0;62
operationsEven = totalEven - firstEvenCount;64
if (firstEven != firstOdd)65
operationsEven += (totalOdd - firstOddCount);67
operationsEven += (totalOdd - secondOddCount);69
operationsOdd = totalOdd - firstOddCount;70
if (firstOdd != firstEven)71
operationsOdd += (totalEven - firstEvenCount);73
operationsOdd += (totalEven - secondEvenCount);75
return min(operationsEven, operationsOdd);