4
bool operator()(pair<int, int> &a, pair<int, int> &b) {5
return a.first < b.first;9
vector<int> rearrangeBarcodes(vector<int> &barcodes) {10
unordered_map<int, int> hmap;11
int n = barcodes.size();12
if (n == 1) return barcodes;14
for (auto &bar : barcodes) {19
priority_queue<pair<int, int>, vector<pair<int, int>>, comp> pq;21
for (auto &it : hmap) {22
pq.push({it.second, it.first});25
while (pq.size() > 1) {26
auto firstBar = pq.top();29
auto secondBar = pq.top();32
ans.push_back(firstBar.second);33
ans.push_back(secondBar.second);38
if (firstBar.first > 0) {42
if (secondBar.first > 0) {48
ans.push_back(pq.top().second);