An electronic crossing engine processes a continuous stream of limit orders. You are given a 2D integer array orders, where orders[i] = [price_i, amount_i, order_type_i]:
order_type_i = 0: Represents a Buy order for amount_i shares at a maximum limit price price_i.order_type_i = 1: Represents a Sell order for amount_i shares at a minimum limit price price_i.Matching Rules (Price-Time Priority):
Your Task
Implement get_number_of_backlog_orders(orders: list[list[int]]) -> int that returns the total quantity of shares remaining in the backlog after processing all orders, modulo .
Constraints
orders[i] = [price, amount, order_type]Examples
orders = [[10, 5, 0], [15, 2, 1], [25, 1, 1], [30, 4, 0]]
# 1. Buy 5 @ 10 -> backlog buy: {10: 5}
# 2. Sell 2 @ 15 -> backlog sell: {15: 2}
# 3. Sell 1 @ 25 -> backlog sell: {15: 2, 25: 1}
# 4. Buy 4 @ 30 -> matches Sell 2 @ 15 (2 shares left), matches Sell 1 @ 25 (1 share left). Remaining 1 buy @ 30 enters backlog.
# Final backlog: Buy {10: 5, 30: 1} -> 6 shares total.
# Output: 6