Back to problems

Remove m Elements to Minimize Unique Count

Algorithm · Walmart Labs · Medium

Requirements Inputs are arr: int[] and m: int, with 0 ≤ m ≤ arr.length. Remove values from any m indices; the sequence in which removals occur is irrelevant. Your goal is to make set(remaining) as small as possible. Output the smallest possible count of unique values left behind. Examples Notes Be prepared to state these two edge cases: when m == 0, return the initial number of unique values; when m == arr.length, return 0 because every element may be deleted. This coding…

Checking your access…