I know we can use merge sort's merging and dividing method to find inversions. But I was wondering about the most optimal way to remove a subarray such that the number of inversions are reduced. We have to delete a subarray of size K. And I know a brute force approach where I keep on deleting subarrays of sizes k and keep on counting the inversions but that takes O(n^2) time. I need something in O(nlogn) or O(n)
k size
in the title