This question appeared on HackWithInfy-2022
Problem Statement
You are given an array of length N containing a permutation of first N natual numbers i.e (1 to N). You are able to apply the following operation at most once. - Choose any subarray of size K and reverse it.
Return the minimum inversions in the array after said operations.
Inversion in an array is defined as a pair of indices (i,j) such that Ai > Aj and i < j.