Practice Number of Orders in the Backlog
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Process orders [price,amount,type] in input order; type 0 buys and type 1 sells. Each amount represents that many individual orders at the same price. A buy matches the lowest-priced waiting sell when that price is no greater than its own; a sell matches the highest-priced waiting buy when that price is no lower than its own. Remove matched units and keep unmatched units waiting. Return the remaining total units modulo 10^9 + 7.
Source: Number of Orders in the Backlog on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
orders = [[10,5,0],[15,2,1],[25,1,1],[30,4,0]]
6
# Example 2
orders = [[7,1000000000,1],[15,3,0],[5,999999995,0],[5,1,1]]
999999984
Constraints
Related LeetCode Problems
Practice more problems similar to Number of Orders in the Backlog.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.