python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
PriorityQueue is not arranging duplicate elements in order [Duplicate elements descending order]
I have used priority queue to store elements in ascending and descending order but when there are duplicate elements it does not store in identical order.
Ascending Order
import java.util.*;
class Pri...
Shubham Khatri
Votes: 0
Answers: 1
Compare function in priority_queue/stl
bool operator() (const pair<int,string>& a,const pair<int,string>& b){
if(a.first!=b.first)
return a.first>b.first;
else
return a.second...
Arham Naeem
Votes: 0
Answers: 1
C++ Finding minimum in vector of structs using custom comparator
I have a vector of structs:
struct element_t {
int val;
bool visited;
};
With a custom comparator:
bool cmp(const element_t& lhs, const element_t& rhs)
{
return ((lhs.val < rhs...
Vojtooo
Votes: 0
Answers: 3
C++ how to declare an array of priority_queue with customed comparator
With the idea from:
declaring a priority_queue in c++ with a custom comparator ,
I tried to use lambda as comparator for the priority_queue, but when I tried to declare an array of it, error comes.
co...
cs108
Votes: 0
Answers: 1