Company: Nebius early talent program_4april
Difficulty: medium
Smart Sale A sales executive has a bag of items, each assigned a specific ID number. Items with the same ID number are easier to sell together. The executive can remove up to m items from the bag. Determine the minimum number of different IDs the bag will contain after removing the allowed number of items. Example 1 The bag contains n = 6 items with ids = [1,1,1,2,2,3], and m = 2 items can be removed. If two items of type 1 are removed, all three types remain. It is better to remove either two items of type 2 or one item of type 3. Either choice leaves two types: ids = [1,1,1,3] or ids = [1,1,1,2,2]. Return 2. Example 2 The bag contains n = 6 items with ids = [1, 2, 3, 1, 2, 2], and m = 3 items can be removed. If the two items of type 1 and one of type 3 are removed, only type 2 remains. Return 1. Constraints 1 ≤ n ≤ 100000 1 ≤ ids[i] ≤ 1000000 1 ≤ m ≤ 100000 /* * Complete the 'deleteProducts' function below. * * The function is expected to return an INTEGER. * The fu