#3768

Minimum Inversion Count in Subarrays of Fixed Length

master · 1645 · lc hard +32 · 42.5% accepted · 48 likes · top 24%

Description

Given an integer array nums of length n and an integer k, where an inversion is an index pair (i, j) with i < j and nums[i] > nums[j], find the subarray of nums with exactly k elements that has the fewest inversions and return that minimum inversion count.

Code

1
2
3