Customer Revenue
Asked at Databricks· Screen
Reported by the problem's creator, not verified
You maintain an in-memory record of customers and the revenue each has brought in. Customers are numbered 0, 1, 2, ... in the order they are added, and revenue is a non-negative integer.
Examples
Example 1
Input: init =
[], operations =[["add",[100]],["add",[40]],["lowest_k",[0,2]],["lowest_k",[41,5]],["add",[40]],["lowest_k",[40,3]],["lowest_k",[40,1]],["lowest_k",[1000,3]]]Output:
[0,1,[1,0],[0],2,[1,2,0],[1],[]]Explanation: After two adds the revenues are 100 and 40, so the lowest 2 with minimum 0 are [1, 0]. With minimum 41 only customer 0 qualifies. Customer 2 also has revenue 40, so the lowest 3 with minimum 40 are [1, 2, 0] (customers 1 and 2 tie on revenue, ordered by number), and
k = 1truncates that to [1]. No customer reaches 1000.