Back to problems

Reduce The Maximum To Even K Times

Algorithm · Oracle · Medium

You are given an array of non-negative integers nums, along with two integers k and m. You need to apply exactly k operations to nums. Each operation follows these steps: Find the current maximum value N present in nums. Replace that maximum value with N - (N % 2). After performing all k operations, return any list that contains the m largest values remaining in nums. The ordering of these m values does not matter. Constraints: 1 ≤ nums.length ≤ 10^5 0 ≤ nums[i] ≤ 10^9 0 ≤ k…

Checking your access…