What is the mistake in this code?
@Deepanshu_garg hey deepanshu you have to take queue instead of deque and order of taking input is also matter
queue and array
alogrithm of this question is
take input n
for i=0 to n
input into queue
take an array
for i=0 to n
take input into array
take three variable executed_job,total_time,job;
initially value of all these will zero
now while queue is not empty
take job=queue.front();
if(job==a[executed_job]
queue.pop();
executed_job++;
total_time++;
else
queue.pop();
queue.push();
total_time++;
}
print total_time
What is problem with deque as i am also using the same method pop_front and push_back and time++ setting the condition as stated in the question,So at what condition by code fails