[Java] Easy 2 Heap solution
java\nclass Solution {\n    public int getNumberOfBacklogOrders(final int[][] orders) {\n        final Queue<int[]> buy = new PriorityQueue<>((a, b) -> b[0] - a
```java\nclass Solution {\n    public int getNumberOfBacklogOrders(final int[][] orders) {\n        final Queue<int[]> buy = new PriorityQueue<>((a, b) -> b[0] - a[0]);\n        final Queue<int[]> sell = new PriorityQueue<>((a, b) -> a[0] - b[0]);\n\n        for(final int[] order : orders) {\n            if(order[2] == 0)\n                buy.offer(new int[] { order[0], order[1] });\n            else\n                sell.offer(new int[] { order[0], order[1] });\n\n            while(!buy.isEmpty() && !sell.isEmpty() && sell.peek()[0] <= buy.peek()[0]) {\n                final int[] sellOrder = sell.peek(), buyOrder = buy.peek();\n\n                final int processed = Math.min(sellOrder[1], buyOrder[1]);\n\n                sellOrder[1] -= processed;\n                buyOrder[1] -= processed;\n\n                if(sellOrder[1] == 0)\n                    sell.poll();\n\n                if(buyOrder[1] == 0)\n                    buy.poll();\n            }\n        }\n\n        int backlog = 0;\n\n        while(!buy.isEmpty())\n            backlog = (backlog + buy.poll()[1]) % 1000000007;\n\n        while(!sell.isEmpty())\n            backlog = (backlog + sell.poll()[1]) % 1000000007;\n\n        return backlog;\n    }\n}\n```
['Java']