Problem library

Loot Ledger

Medium
hash mapsorting

Every entry in changes is [item, amount]: a positive amount adds that many of the item to the inventory and a negative amount removes them.

Return the final inventory as a list of [item, count] pairs for items whose final count is greater than zero, sorted by item name.

Examples

Input: changes = [["gem",3],["key",1],["gem",-1],["key",-1]]
Output: [["gem",2]]
Input: changes = []
Output: []