queue.back() always has some value even after popping all elements of queue why?

your textwhen i traverse through queue and print elements, after the traversal size of queue is zero, but queue.back() is printing the last value, can you help me. Code s.back() should print zero but it is printing 30. >Solution : A C++ program that compiles and seems to run is not necessarily a correct program.… Read More queue.back() always has some value even after popping all elements of queue why?

Dequeue function is not working correctly

#include<stdio.h> #include<string.h> #include<stdlib.h> #define max 100 int enqueue(); int dequeue(); int peek(); int main() { char name[max][80], data[80]; int front = 0; int rear = 0; int value; int ch; printf("——————————\n"); printf("\tMenu"); printf("\n——————————"); printf("\n [1] ENQUEUE"); printf("\n [2] DEQUEUE"); printf("\n [3] PEEK"); printf("\n [4] DISPLAY"); printf("\n——————————\n"); while(1) { printf("Choice : "); scanf("%d", &ch); switch(ch) {… Read More Dequeue function is not working correctly

Unable to retrieve multiple values from database

The following data exists in the database: [ { "_id": { "$oid": "628c787de53612aad30021ab" }, "ticker": "EURUSD", "dtyyyymmdd": "20030505", "time": "030000", "open": "1.12161", "high": "1.12209", "low": "1.12161", "close": "1.12209", "vol": "561", "id": 1 }, { "_id": { "$oid": "628c787de53612aad30021ac" }, "ticker": "EURUSD", "dtyyyymmdd": "20030505", "time": "030100", "open": "1.12206", "high": "1.1225", "low": "1.12206", "close": "1.1225", "vol": "1223",… Read More Unable to retrieve multiple values from database

Python priority queue- subsequent pops return wrong values after first pop?

I am trying to solve Leetcode #347 Top K Frequent elements using a priority queue. However, my code is failing some test cases. Here is the code: from queue import PriorityQueue class Solution: def topKFrequent(self, nums: List[int], k: int) -> List[int]: counts = {} mynums = set() q = PriorityQueue() for num in nums: if… Read More Python priority queue- subsequent pops return wrong values after first pop?