Company: Nebius early talent program_4april
Difficulty: medium
Smart Sale A vendor has a crate of items, each tagged with an ID number, and items sharing an ID move faster as a set. The vendor may pull out up to m items from the crate. Work out the fewest distinct IDs that can remain in the crate once the allowed number of removals is used. Example 1 The crate holds n = 6 items with ids = [1,1,1,2,2,3], and up to m = 2 removals are allowed. Pulling out the two type-1 items still leaves all three types behind. A better move is removing the two type-2 items, or just the single type-3 item — either way only two distinct types remain: ids = [1,1,1,3] or ids = [1,1,1,2,2]. So the answer is 2. Example 2 The crate holds n = 6 items with ids = [1, 2, 3, 1, 2, 2], and up to m = 3 removals are allowed. Removing the two type-1 items plus the one type-3 item leaves only type 2 behind, so the answer is 1. Constraints 1 ≤ n ≤ 100000 1 ≤ ids[i] ≤ 1000000 1 ≤ m ≤ 100000 /* * Complete the 'deleteProducts' function below. * * The function is expec