Search
⌘K

Leetcode 3134. Find the Median of the Uniqueness Array

Find the median of the multiset formed by the number of distinct elements in every subarray of nums — i.e., determine the k-th smallest value of distinct(nums[i..j]) over all O(n^2) subarrays. Key insight: the predicate "number of subarrays with ≤ t distinct elements" is monotone and can be computed with a sliding-window frequency map, enabling a binary search over t to locate the median.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.