Tap here to switch tabs
Problem
Submissions

Problem: Minimum Inversion Count in Subarrays of Fixed Length

Minimum Inversion Count in Subarrays of Fixed Length examines every contiguous subarray of length k and returns the smallest number of pairs where an earlier element is greater than a later one.

Statement

You are given an integer array nums of length n and an integer k.

An inversion in a subarray is defined as a pair of indices (i,j)(i, j) such that 0≤i<j<0 \leq i < j < k and the element at index ii is strictly greater than the element at index jj.

Return the minimum number of inversions among all contiguous subarrays of length k.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Inversion Count in Subarrays of Fixed Length

Minimum Inversion Count in Subarrays of Fixed Length examines every contiguous subarray of length k and returns the smallest number of pairs where an earlier element is greater than a later one.

Statement

You are given an integer array nums of length n and an integer k.

An inversion in a subarray is defined as a pair of indices (i,j)(i, j) such that 0≤i<j<0 \leq i < j < k and the element at index ii is strictly greater than the element at index jj.

Return the minimum number of inversions among all contiguous subarrays of length k.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤109\leq 10^9

  • 1≤1 \leq k ≤\leq n