Help with approach

problem: https://hack.codingblocks.com/app/contests/2022/967/problem

for inserting the bottom element of a stack do we take another stack and push it there? If not then what do we do

  • The Idea is to 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.