Question
Valid Queue You are given a queue of integers. Check if the queue is valid. A valid queue is one in which the numbers are
Valid Queue
You are given a queue of integers. Check if the queue is valid. A valid queue is one in which the numbers are inserted in ascending order.
?The queue (5, 44, 333) is a valid queue while the queue (5,44,33) is not.
Input and Output:
The function should take a queue of integers as input and return true or false as output. If the queue is empty return true.
Note: You are given the STL Functions and you are free to use them:
Queue
??empty() Returns whether the queue is empty ??size() Returns the size of the queue ??push(g) Adds the element g at the end of the queue ??pop() Deletes the first element of the queue
??front() Returns a reference to the first element of the queue
??back() Returns a reference to the last element of the queue
Sample Input 1:
4 44 333
Sample Output 1:
true
Sample Input 2:
4 44 33
Sample Output 2:
false
Sample Input 3:
-5 6 11
Sample Output 3:
true
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started