Skip to content

Instantly share code, notes, and snippets.

@onkar27
Created July 13, 2018 17:37
Show Gist options
  • Save onkar27/87666d2d4929bb925bbb5e225987d4b7 to your computer and use it in GitHub Desktop.
Save onkar27/87666d2d4929bb925bbb5e225987d4b7 to your computer and use it in GitHub Desktop.
Heaps using C++ STL
// max heap
priority_queue <ll> max_heap; // by defualt priority_queue is maxheap always.
// min heap
priority_queue <ll, vector<ll>, greater<ll> > min_heap;
// type, container, comparator function
typedef struct mystruct {
ll one;
ll two;
bool operator < (const mystruct t) const {
one < t.one;
}
}mystruct;
priority_queue <mystruct> heapofStruct;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment