#C10299. Inventory Update: Adjusting Warehouse Stock
Inventory Update: Adjusting Warehouse Stock
Inventory Update: Adjusting Warehouse Stock
You are given two JSON objects representing inventories. The first JSON object is the current inventory of a warehouse, where keys are item names and values are their quantities. The second JSON object represents a shipment arriving at the warehouse. Your task is to update the current inventory by adding the quantities from the shipment. If an item appears in the shipment and does not exist in the current inventory, add it.
The operation can be mathematically represented as follows:
$$I_{updated}(x) = I_{current}(x) + I_{shipment}(x) \quad \text{for each item } x, $$where if an item is missing in I_current, it is treated as 0.
inputFormat
The input consists of two lines read from standard input. The first line is a JSON object representing the current inventory, and the second line is a JSON object representing the shipment inventory.
Example Input:
{"apple": 10, "banana": 5, "orange": 7} {"banana": 3, "orange": 12, "grape": 10}
outputFormat
Output the updated inventory as a JSON object to standard output. The updated inventory is obtained by adding quantities from the shipment to the current inventory. The order of keys in the output does not matter.
Example Output:
{"apple": 10, "banana": 8, "orange": 19, "grape": 10}## sample
{"apple": 10, "banana": 5, "orange": 7}
{"banana": 3, "orange": 12, "grape": 10}
{"apple": 10, "banana": 8, "orange": 19, "grape": 10}