sir mai agar ek baari hi saara ek saara elelment stack B
m daal donga toh ek baari hi mujhe saaare top kar dongaa
b se
Queue using two stack
I cannot understand your question. Can you elaborate
For each query to find the first element in the queue, you will have to transfer all the elements from one stack to another (Since first element of the queue will be at the bottom in first stack)
You cannot store or compute all the tops from before(in one go) because it is not necessary that always the query will be find the first element in the queue. If some query is to delete or push new element in the queue in between, then it will disturb your precomputed top values.