C++ | Priority Queue | 0ms | 100%
\nclass Solution {\npublic:\n    string strWithout3a3b(int a, int b) {\n        priority_queue<pair<int, char>> pq;\n        if(a) pq.push({a,\'a\'});\n        
```\nclass Solution {\npublic:\n    string strWithout3a3b(int a, int b) {\n        priority_queue<pair<int, char>> pq;\n        if(a) pq.push({a,\'a\'});\n        if(b) pq.push({b,\'b\'});\n        string ans = "";\n        while(pq.size()>1){\n            pair<int, char> one = pq.top(); pq.pop();\n            pair<int, char> two = pq.top(); pq.pop();\n            \n            if(one.first >= 2){\n                ans+= one.second;\n                ans+= one.second;\n                one.first -=2;\n            }\n            else{\n                ans+= one.second;\n                one.first -=1;\n            }\n            \n            if(two.first >= 2 && two.first >= one.first){\n                ans+= two.second;\n                ans+= two.second;\n                two.first -=2;\n            }\n            else{\n                ans+= two.second;\n                two.first -=1;\n            }\n            if(one.first > 0)\n                pq.push(one);\n            if(two.first > 0)\n                pq.push(two);\n        } \n        if(pq.empty())\n            return ans;\n        if(pq.top().first >= 2){\n            ans += pq.top().second;\n            ans += pq.top().second;\n        }\n        else{\n            ans += pq.top().second;\n        }\n        return ans;\n        \n    }\n};\n```
['C', 'Heap (Priority Queue)', 'C++']