Question: write a program that Reverse the first ' k ' elements of a queue, push it back into the queue. For example, if the queue
write a program that Reverse the first ' k ' elements of a queue, push it back into the queue. For example, if the queue has members 10,20,30,40,50,60,70,80,90 and first 5 numbers are asked to be reversed then the result will be 60,70,80,90,50,40,30,20,10. Input: 10 20 30 40 50 60 70 80 90 Output: 60 70 80 90 50 40 30 20 10[do it an easy way in python]
Step by Step Solution
There are 3 Steps involved in it
python from collections import deque def reversekelementsqueue k ... View full answer
Get step-by-step solutions from verified subject matter experts
