Play around with a queue.
You will be given:
-
An integer N representing the amount of elements to enqueue (add)
-
An integer S representing the amount of elements to dequeue (remove/poll) from the queue
-
An integer X, an element that you should check whether is present in the queue.
If it is print true on the console, if it’s not print the smallest element currently present in the queue. If the stack is empty print 0.
Examples:
Input
|
Output
|
5 2 32
1 13 45 32 4
|
true
|
4 1 665
665 69 13 420
|
13
|
3 3 90
90 90 90
|
0
|
For the 1st task (with 5 2 32...) comment: We have to push 5 elements. Then we pop 2 of them. Finally, we have to check whether 32 is present in the stack. Since it is we print true.