We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<stdio.h>#include<stdlib.h>#define MAX 100010longintqueue_arry[MAX];longintfront=-1;longintrear=-1;voidEnqueue();voidDequeue();voiddisplay();voidEnqueue(){if(front==-1)front=0;longintx;scanf("%ld",&x);rear=rear+1;queue_arry[rear]=x;}voidDequeue(){front=front+1;}voiddisplay(){printf("%ld \n",queue_arry[front]);}intmain(){intc,i;longintn;scanf("%ld",&n);for(i=0;i<n;i++){scanf("%d",&c);if(c==1){Enqueue();}elseif(c==2){Dequeue();}elseif(c==3){display();}else{}}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Queue using Two Stacks
You are viewing a single comment's thread. Return to all comments →
Very simple solution in C