1
# Runtime: 3233 ms (Top 5.15%) | Memory: 31.6 MB (Top 46.98%)3
def minimumOperations(self, nums: List[int]) -> int:5
odd, even = defaultdict(int), defaultdict(int)11
topEven, secondEven = (None, 0), (None, 0)13
if even[num] > topEven[1]:14
topEven, secondEven = (num, even[num]), topEven15
elif even[num] > secondEven[1]:16
secondEven = (num, even[num])17
topOdd, secondOdd = (None, 0), (None, 0)19
if odd[num] > topOdd[1]:20
topOdd, secondOdd = (num, odd[num]), topOdd21
elif odd[num] > secondOdd[1]:22
secondOdd = (num, odd[num])23
if topOdd[0] != topEven[0]:24
return n - topOdd[1] - topEven[1]26
return n - max(secondOdd[1] + topEven[1], secondEven[1] + topOdd[1])