<p>You are given a <strong>0-indexed</strong> array <code>nums</code> consisting of <code>n</code> positive integers.</p>

<p>The array <code>nums</code> is called <strong>alternating</strong> if:</p>

<ul>
	<li><code>nums[i - 2] == nums[i]</code>, where <code>2 &lt;= i &lt;= n - 1</code>.</li>
	<li><code>nums[i - 1] != nums[i]</code>, where <code>1 &lt;= i &lt;= n - 1</code>.</li>
</ul>

<p>In one <strong>operation</strong>, you can choose an index <code>i</code> and <strong>change</strong> <code>nums[i]</code> into <strong>any</strong> positive integer.</p>

<p>Return <em>the <strong>minimum number of operations</strong> required to make the array alternating</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [3,1,3,2,4,3]
<strong>Output:</strong> 3
<strong>Explanation:</strong>
One way to make the array alternating is by converting it to [3,1,3,<u><strong>1</strong></u>,<u><strong>3</strong></u>,<u><strong>1</strong></u>].
The number of operations required in this case is 3.
It can be proven that it is not possible to make the array alternating in less than 3 operations. 
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,2,2,2,2]
<strong>Output:</strong> 2
<strong>Explanation:</strong>
One way to make the array alternating is by converting it to [1,2,<u><strong>1</strong></u>,2,<u><strong>1</strong></u>].
The number of operations required in this case is 2.
Note that the array cannot be converted to [<u><strong>2</strong></u>,2,2,2,2] because in this case nums[0] == nums[1] which violates the conditions of an alternating array.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
	<li><code>1 &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution:
    def minimumOperations(self, nums: List[int]) -> int:
        l1=nums[::2]
        l2=nums[1::2]
        mapL1={}
        mapL2={}
        flag=False
        for i in range(len(nums)):
            if(i+1<len(nums) and nums[i]!=nums[i+1]):
                flag=True
        if flag==False:
            return len(nums)//2
        for i in l1:
            if i in mapL1:
                mapL1[i]+=1
            else:
                mapL1[i]=1

        for i in l2:
            if i in mapL2:
                mapL2[i]+=1
            else:
                mapL2[i]=1
        max1=0
        max11=0
        num1=None
        max2=0
        max22=0
        num2=None
        # Iterating through the first dictionary to find max and second max
        for num, count in mapL1.items():
            if count > max1:
                max11 = max1  # Update second max
                num1=num
                max1 = count  # Update max
            elif count > max11:
                max11 = count  # Update second max if count is greater than second max but less than max

        # Iterating through the second dictionary to find max and second max
        for num, count in mapL2.items():
            if count > max2:
                max22 = max2  # Update second max
                num2=num
                max2 = count  # Update max
            elif count > max22:
                max22 = count  # Update second max if count is greater than second max but less than max

        print(mapL1)
        print(mapL2)        
        print(max11)
        print(max22)
        if(num1==num2):
                return min(len(l1)-max1 + len(l2)-max22,len(l1)-max11 + len(l2)-max2)

        return len(l1)-max1 + len(l2)-max2
917