Company: IBM SDE off-campus_19april
Difficulty: medium
HackerCards is a card game where each card type has a unique ID greater than or equal to 1, and the cost of a card is equal to its ID. Leanne already owns the cards listed in collection . Mike wants to buy her as many additional cards as possible within a budget d , subject to the following rules: he can buy at most one of each card he cannot buy any card that Leanne already owns the total cost of the purchased cards must be at most d if multiple choices are possible, he always prefers the lowest-cost cards first Return the IDs of the cards Mike will buy, in ascending order. Example collection = [2, 4, 5] d = 7 Leanne owns the cards in collection , and Mike has d = 7 to spend. He can purchase a maximum of 2 cards, cards 1 and 3, to add to her collection. Two other options he has are 1 and 6 (costs more) or 7 (fewer cards, costs more). Function Description Complete the function hackerCards in the editor with the following parameter(s): int collection[n] : the ID numbers of cards in Lean