C++ priority Queue based solution || beginner friendly code
\nclass Solution {\npublic:\n    int getNumberOfBacklogOrders(vector<vector<int>>& orders) {\n        \n        priority_queue<pair<int,int>,vector<pair<int,int
```\nclass Solution {\npublic:\n    int getNumberOfBacklogOrders(vector<vector<int>>& orders) {\n        \n        priority_queue<pair<int,int>,vector<pair<int,int>> > buy; //max queue for buy\n        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>> >sell;//min queue for sell\n        \n        for(auto x:orders){\n            \n            if(x[2]==0){\n                buy.push({x[0],x[1]});\n                int flag=0;\n                while(sell.size()>0 && sell.top().first<=x[0] && x[1]>0){\n                    flag=1;\n                    buy.pop();\n                    auto t = sell.top();\n                    sell.pop();\n                    if(t.second<x[1]){\n                        \n                        buy.push({x[0],x[1]-t.second});\n                        x[1] = x[1] - t.second;//decrease the size of remaining items as well\n                        \n                    }\n                    else{\n                        sell.push({t.first,t.second-x[1]});\n                        x[1] = 0;//all the items got finished\n                    }\n                }\n                \n                \n                    \n                \n                \n            }\n            \n            if(x[2]==1){\n                \n                int flag=0;\n                sell.push({x[0],x[1]});\n                while(buy.size()>0 && buy.top().first>=x[0] && x[1]>0){\n                    flag=1;\n                    auto t = buy.top();\n                    sell.pop();\n                    buy.pop();\n                    if(t.second<x[1]){\n                        \n                        sell.push({x[0],x[1]-t.second});\n                        x[1]= x[1] -t.second;//decrement the remaining item\n                    }\n                    else{\n                        buy.push({t.first,t.second-x[1]});\n                        x[1] = 0;//all the item got finished\n                    }\n                }\n                \n                \n                    \n                \n                \n            }\n            \n        }\n\t\t//now count the number of items remaining in the queues;\n        int count =0;\n        while(buy.size()){\n            \n            count = (count + buy.top().second)%1000000007;\n            buy.pop();\n        }\n        \n         while(sell.size()){\n            \n            count = (count + sell.top().second)%1000000007;\n            sell.pop();\n        }\n        \n        return count;\n        \n    }\n};\n```\n\n**Hit like if you liked:: ,, Happy Coding :)**
['C', 'Heap (Priority Queue)', 'C++']