jeudi 6 octobre 2022

Difference in queue sizes giving arbitrarily large value C++

#include <iostream>
#include <queue>

using namespace std;

int main()
{
    // cout<<"Hello World";

    priority_queue<int> spq;  // max heap
    priority_queue <int, vector<int>, greater<int>> lpq; // min heap
    
    
    spq.push(1);
    
    lpq.push(2);
    lpq.push(3);
    
    
    cout << spq.size() - lpq.size() << endl;
    
    
    return 0;
}

This code is giving me un-expectedly very large value of 18446744073709551615

I am not able to understand the issue here.

Aucun commentaire:

Enregistrer un commentaire