<p>You are given an integer array <code>nums</code> of size <code>n</code> where <code>n</code> is <strong>even</strong>, and an integer <code>k</code>.</p>

<p>You can perform some changes on the array, where in one change you can replace <strong>any</strong> element in the array with <strong>any</strong> integer in the range from <code>0</code> to <code>k</code>.</p>

<p>You need to perform some changes (possibly none) such that the final array satisfies the following condition:</p>

<ul>
	<li>There exists an integer <code>X</code> such that <code>abs(a[i] - a[n - i - 1]) = X</code> for all <code>(0 &lt;= i &lt; n)</code>.</li>
</ul>

<p>Return the <strong>minimum</strong> number of changes required to satisfy the above condition.</p>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,0,1,2,4,3], k = 4</span></p>

<p><strong>Output:</strong> <span class="example-io">2</span></p>

<p><strong>Explanation:</strong><br />
We can perform the following changes:</p>

<ul>
	<li>Replace <code>nums[1]</code> by 2. The resulting array is <code>nums = [1,<u><strong>2</strong></u>,1,2,4,3]</code>.</li>
	<li>Replace <code>nums[3]</code> by 3. The resulting array is <code>nums = [1,2,1,<u><strong>3</strong></u>,4,3]</code>.</li>
</ul>

<p>The integer <code>X</code> will be 2.</p>
</div>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [0,1,2,3,3,6,5,4], k = 6</span></p>

<p><strong>Output:</strong> <span class="example-io">2</span></p>

<p><strong>Explanation:</strong><br />
We can perform the following operations:</p>

<ul>
	<li>Replace <code>nums[3]</code> by 0. The resulting array is <code>nums = [0,1,2,<u><strong>0</strong></u>,3,6,5,4]</code>.</li>
	<li>Replace <code>nums[4]</code> by 4. The resulting array is <code>nums = [0,1,2,0,<strong><u>4</u></strong>,6,5,4]</code>.</li>
</ul>

<p>The integer <code>X</code> will be 4.</p>
</div>

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

<ul>
	<li><code>2 &lt;= n == nums.length &lt;= 10<sup>5</sup></code></li>
	<li><code>n</code> is even.</li>
	<li><code>0 &lt;= nums[i] &lt;= k &lt;= 10<sup>5</sup></code></li>
</ul>

class Solution:
    def minChanges(self, nums: List[int], k: int) -> int:
        n=len(nums)
        dif=[]
        has={}
        for i in range(n//2):
            val=abs(nums[i]-nums[n-i-1])
            dif.append(val)
            if val in has:
                has[val]+=1
            else:
                has[val]=1
        count=[]
        for i in has:
            count.append([has[i],i])
        count.sort(key=lambda element: (-element[0], element[1]))
        diff=count[0][1]
        min_cot=999999999
        #print(diff)
        c=len(count)
        ind=0
      
        while ind<c and ind<2:
            
            diff=count[ind][1]
            cot=0
            ind+=1
            for i in range(n//2):
                val=abs(nums[i]-nums[n-i-1])
                if val!=diff:
                    if val>diff:
                        #print("val greater")
                        act_diff=val-diff
                        #print(act_diff)
                        #print("values",nums[i],nums[n-i-1])
                        if nums[i]>nums[n-i-1]:
                            if nums[i]-act_diff>=0 or nums[n-1-i]+act_diff<=k:
                                cot+=1
                            else:
                                cot+=2
                        else:
                            if nums[n-i-1]-act_diff>=0 or nums[i]+act_diff<=k:
                                cot+=1
                            else:
                                cot+=2
                    else:
                        #print("val lesss")


                        act_diff=diff-val
                        #print(act_diff)
                        #print("values",nums[i],nums[n-i-1])
                        if nums[i]>nums[n-i-1]:
                            if nums[i]+act_diff<=k or nums[n-1-i]-act_diff>=0:
                                cot+=1
                            else:
                                cot+=2
                        else:
                            if nums[n-i-1]+act_diff<=k or nums[i]-act_diff>=0:
                                cot+=1
                            else:
                                cot+=2
                        
            min_cot=min(min_cot,cot)    
                
                
        return min_cot
33700