MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / enque

Method enque

GeeksForGeeks/StackUsingQueus/solution.cpp:17–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15 queue<int> q2;
16
17 void enque(int x)
18 {
19 // Push x first in empty q2
20 q2.push(x);
21
22 // Push all the remaining elements in q1 to q2.
23 while(!q1.empty())
24 {
25 q2.push(q1.front());
26 q1.pop();
27 }
28 // Swap the names of two queues
29 queue<int> temp = q1;
30 q1 = q2;
31 q2 = temp;
32 }
33
34 int dequeue()
35 {

Callers 1

mainFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected