Importance of time

https://ide.codingblocks.com/s/198859 Hi Can you help me out with this approach ?

@abhishekjohri98,

https://ide.geeksforgeeks.org/nN7C0CW4sP corrected code.

Store the Calling order in Queue and the ideal order in an Array.
Then compare front element of the queue with the ideal order.
If it matches then increment the time and remove the element.
Else, Dequeue the element and enqueue it again.
The loop will run till the queue is consumed totally.

Why it won’t work if we take the actual processes also in a queue ?

@abhishekjohri98,
It can work in a queue as well but accessing the element will be a tedious task

Thank you I got it now