I got stuck with the problem tried but getting wrong answer.Please help
Here is the link
https://ide.codingblocks.com/s/73015
Importance of time
@Vijay hey vijay your approach is wrong this question is solved using
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