Priority Queue in C++

PHOTO EMBED

Mon Sep 18 2023 14:46:59 GMT+0000 (Coordinated Universal Time)

Saved by @sahil002

auto compare = [](const std::pair<char, int>& lhs, const std::pair<char, int>& rhs) {
        return lhs.second < rhs.second;
    };

    // Create a priority queue of pairs (char, int) using the custom comparison function
    std::priority_queue<std::pair<char, int>, std::vector<std::pair<char, int>>, decltype(compare)> pq(compare);
content_copyCOPY

when u want to create a priority queue in which u store a pair where 2nd value of pair is greater on top

https://chat.openai.com/