← 返回 snowflake 的题目列表Book Sales Leaderboard
类型:online_judge
We are building a system that tracks book sales and updates a leaderboard of best selling books.
First, decide how to store the current state of book sales. Next, implement an update function that takes in new sales records, updates the current state, and returns a list of the K top selling titles.
List<string> bestSellers(Map<string, int> sales, Integer k)
Example:
bestSellers({"a": 5, "b": 10, "c": 15}, 2) -> ["c", "b"]
bestSellers({"a": 20, "b": 20, "c": 5}, 2) -> ("b", "a") a=25
Example
Input
{"a": 5, "b": 10, "c": 15}
2