Points From Distinct Categories

Asked at MetaPhone screen

Reported by the problem's creator, not verified

You are given items, a list of [category, points] pairs, and an integer k.

Examples

  1. Example 1

    Input: items = [[1,10],[2,5],[1,7],[3,8]], k = 2

    Output: 18

    Explanation: Category 1's best item is worth 10, category 2's is 5 and category 3's is 8. The two largest of these are 10 and 8, so the answer is 18. Taking 10 and 7 would reuse category 1.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.