For Creating a Queue Q we use two Stack S1,S2. for insert x in the end of Q we do Push(S1,x). for deleting element from front of Q, (if Q is not empty) we do Pop(S2). if on Q that at first is empty, we do 100 operation (insert or delete from front or end or arbitrary sequence). What is the maximum Cost? each Pop and Push is 1 Cost.
My solution:
i think 50 push and 50 pop * 2 =200.
any idea or solution highly appreciated.
Since each operation costs 1, we can gain maximum when all operations do some pushing/popping. The best way to do is 50 push and 50 pops which correspond to $50\times1+50\times1=100$