Skip to main content

Posts

Showing posts with the label InfoEdge

Implement Queue using Stack [EASY/IMPORTANT]

Company:Flipkart, De-Shaw, Amazon, Adobe, Accolite, Inmobi, Microsoft, MAQ-Software, MakeMyTrip, InfoEdge, Goldman-Sachs, Walmart-Labs, Oracle Question: Implement a Queue using 2 stacks  s1  and  s2  . Input  : The first line of the input contains an integer ' T ' denoting the number of test cases. Then T test cases follow. First line of each test case contains an integer  Q  denoting the number of queries .  A Query  Q  is of 2 Types (i)  1 x   (a query of this type means  pushing  'x'  into the queue) (ii)  2     (a query of this type means to pop element from queue and print the poped element) The second line of each test case contains  Q  queries seperated by space. Output: The output for each test case will  be space separated integers having  -1  if the queue is empty else the element poped out from the queue .  You are...