need some hints as unable to find approach for it
Importance of Time
Hey @Divya_321 try to formulate your logic by incorporating the data structure βQueueβ in your approach.
@sdevwrat this is my codeLink:de.codingblocks.com/s/182206
I have according to me is working just fine but itβs giving me wrong ans please point out my mistake and correct it
Hey @Divya_321 your updation of time1 variable is not correct in the else part. It should be incremented by 1 for every pop operation and once again incremented when you come out of the loop. Take a look at the following snippet of code.
else{
while(calling.front()!=order[i]){
int temp = calling.front();
calling.pop();
calling.push(temp);
time1++;//once update here
}
time1 ++;//final update
calling.pop();
//cout<<order[i]<<" β<<time1<<β "<<calling.front()<<endl;
}