#3759

Count Elements With at Least K Greater Values

medium · 31.2% accepted · 70 likes · top 9%

array · binary search · divide and conquer · sorting · quickselect

Description

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

An element in nums is said to be qualified if there exist at least k elements in the array that are strictly greater than it.

Return an integer denoting the total number of qualified elements in nums.

Solution