Priority Queue ease solu C++
class Solution {\npublic:\n    int fillCups(vector& amount) {\n        priority_queue q;\n        \n        // fill qunatity of cups\n        for(int i=0; i0)q.
class Solution {\npublic:\n    int fillCups(vector<int>& amount) {\n        priority_queue<int> q;\n        \n        // fill qunatity of cups\n        for(int i=0; i<amount.size(); i++){\n            if(amount[i]>0)q.push(amount[i]);\n        }\n        \n        int day = 0;\n        while(!q.empty() && q.size()>1){\n            // check first two elements decrease them and again push to priority queue\n            int a = q.top() - 1;\n            q.pop();\n            \n            int b = q.top() - 1;\n            q.pop();\n            \n            day++;\n            if(a>0) q.push(a);\n            if(b>0) q.push(b);\n        }\n        \n        // check if any element is left\n        if(q.size()) day+=q.top();\n        \n        return day;\n\n    }\n};
['Heap (Priority Queue)']