fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7. // max heap
  8. priority_queue<int>maxHeap;
  9. maxHeap.push(10);
  10. maxHeap.push(5);
  11. maxHeap.push(20);
  12. maxHeap.push(15);
  13.  
  14. // while(maxHeap.size() > 0)
  15. // {
  16. // cout << maxHeap.top() << endl;
  17. // maxHeap.pop();
  18. // }
  19.  
  20. // minHeap making
  21. priority_queue<int , vector<int>,greater<int>> minHeap; // fast o priority_queue maxHeap make korbe, then vector ta save kore rakbe, then grater ta minheap convert korbe
  22.  
  23. minHeap.push(10);
  24. minHeap.push(5);
  25. minHeap.push(20);
  26. minHeap.push(15);
  27. while(minHeap.size() > 0)
  28. {
  29. cout << minHeap.top() << endl;
  30. minHeap.pop();
  31. }
  32.  
  33. // for(int i =0; i< maxHeap.size();i++)
  34. // {
  35. // cout<< maxHeap.top() << endl;
  36. // maxHeap.pop();
  37. // }
  38. // cout << maxHeap.top() << endl;
  39.  
  40.  
  41.  
  42.  
  43. // vector<int> v[10]; // 1 Demensional array // dynamic // created throught linked list but act like an array
  44. // vector<vector<int>>v;
  45. // for(int i = 0; i < 10;i++)
  46. // v[i].push_back(5);
  47.  
  48. // for(int i = 0; i < 10;i++)
  49. // {
  50. // for(int j = 0; j<v[i].size();j++)
  51. // cout << v[i][j];
  52. // cout << endl;
  53. // }
  54.  
  55. // v.push_back(5);
  56. // v.push_back(10);
  57. // for(int i =0; i< v.size();i++)
  58. // {
  59.  
  60. // cout << v[i] << " " ;
  61. // }
  62.  
  63.  
  64.  
  65. return 0;
  66. }
  67.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
5
10
15
20