Sir i do not understand question .please can you explain

importance of time question of stack

@dineshjani
Basically is question me hme n dia hai and two arrays di hai pehle array me order hai ki kis order me process execute horhi hai real me and 2nd array me ideal order mtlb is order me ideally hona chyy.Executing and changing position of prcoess me hme 1 unit time lgta hai and hme total time btana hai jisme sari process complete hojaye bs condition ye hai ki index of process in ideal order should be same as calling order and hm position change kr skte hai calling hai woh extra time add krna pdega total time ,…eg lelo ye jo testcase dia hai ,hm isme queue use kr skte hai ,ye test case me 5
5 4 2 3 1
5 2 1 4 3 just now ✓
You have two arrays, ar1[ ] and ar2[ ]
You will take ar1[ ] and push its elements in queue, with initializing total time as 0. Then you will check if the front most element in the queue matches with the ar2[ ] first element, i.e
5 matches with 5 , thus total _time =1;
Then front element of queue becomes 4, and now 4 doesnt matches with 1, thus you will pop 4 from queue, and push it in end, total_time =2
Then front element of queue is 2, and 2 matches with 2 present in ar2[ ], thus you will pop 2 from queue and then total_time=3
Then front of queue becomes 3, and 3 doesnt match with 1 , and hence you pop it and push 3 in the end of queue, total_time=4
1 is next element of queue, which matches with the 1 present in ar2[ ] and hence total_time=5

Keep on doing this until all elements are popped from queue,
Final value after popping all elements from queue will be 7

Hope you get it :slight_smile: