Importance of time problem


help me out with this please

Dhruv, you are using a wrong approach to solve this question. You have to use 1 array and 1 queue, and you need to maintain 3 variables as total_time, job, executed_job all initialised to 0. Then you will check that
while (!q.empty())
{
job=q.front();
if(job==ar[executed_job])
{
total_time++;
executed_job++;
q.pop();
}
else
{
q.pop();
q.push();
total_time++;
}

Try using this logic

I dry ran my code and the output was coming exactly same but in answer it was not can you tell me mistake in my code

mam plz reply fast its been 3days without a reply

I check again your code. plz wait

The problem with the code is that the while loop is not getting executed, as pointer is not getting updated, try using the loop first before checking while condition, since value of pointer is not getting updated,


see in this code, I was trying to print values of t, but it is not getting printed, thats why using 1 array is a better option, since in array you can move the pointer easily


You can refer to this for your reference

okk thanks ill try again

please tell me my mistake