Modifying input Array O(1) space compelxity beats 100% with proof 
IntuitionMODIFYING INPUT ARRAYApproachBRUTEComplexity
Time complexity:
O(N^2)
Space complexity:
O(1)//
//Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
MODIFYING INPUT ARRAY

# Approach
<!-- Describe your approach to solving the problem. -->
BRUTE
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
O(N^2)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1)


//
![Screenshot (20).png](https://assets.leetcode.com/users/images/d8e4dec9-7f92-469e-8db1-5092daabfdce_1744080556.7837198.png)

//
# Code
```java []
class Solution {
    public int minimumPairRemoval(int[] nums) {
        int count=0;
       while(!issorted(nums)){
        nums=min(nums);
        count++;
       }
       return count;
    }
    boolean issorted(int []nums){
        for(int i=0;i<nums.length-1;i++){
            if(nums[i]>nums[i+1])return false;
        }
        return true;
    }
    int [] min(int nums[]){
        int i=0,j=1,min=Integer.MAX_VALUE,idx=-1;
        while(j<nums.length){
            int sum=nums[i]+nums[j];
            if(sum<min){
                min=sum;
                idx=i;
            }
            i++;
            j++;
        }
        nums[idx]=min;
        for(i=idx+1;i<nums.length-1;i++){
            nums[i]=nums[i+1];
        }
        return Arrays.copyOfRange(nums,0,i);
    }
}
```
['Java']