Algorithm · Capital One · Medium
You are given an integer array nums and an integer k. Count how many contiguous subarrays hold at least k pairs of equal elements, where the chosen pairs must be pairwise disjoint. Here a pair means two elements of the subarray with the same value, and no element may belong to more than one chosen pair. So a value appearing freq times inside the subarray can supply at most $$\lfloor freq / 2 \rfloor$$ disjoint pairs, and the total number of disjoint equal pairs in a subarray…