Algorithm · Microsoft · Medium
For an integer array nums and an integer k, build and return an array that contains exactly the k largest values from nums, keeping those values in the same relative order they had in the original array. Each occurrence in nums is considered separately. If the threshold value appears more times than necessary, retain only the earliest occurrences of that value so the result has exactly k elements. When k = nums.length, return a copy of the original array. Example 1:…
Checking your access…