A warehouse's system says it holds expected (a dict item -> quantity). A stock take produced scanned, a list of item names, one per unit found. Return a dict of discrepancies: for every item whose scanned quantity differs from the expected quantity, map the item to scanned - expected. Items scanned but not expected count as expected 0; expected items never scanned count as scanned 0. Items that match are left out.
Examples
Input: expected = {"bolt": 3, "nut": 2}
scanned = ["bolt", "bolt", "nut", "nut", "nut", "washer"]
Output: {"bolt": -1, "nut": 1, "washer": 1}
Input: expected = {"gear": 2}, scanned = []
Output: {"gear": -2}
Constraints
0 <= len(expected), len(scanned) <= 10**5- Target complexity: O(n + m) time.
Goals
- Compare a count dict against a list of observations
- Report only the keys that differ, from both sides