There are two stacks A and B.
A : a,b,c,d ('a' is on top and 'd' is at the bottom of the stack) B : (empty)
There are two rules.
If an element of A is popped, it must be printed immediately or pushed into B. If an element of B is popped, it can only be printed.
So, how many permutations of a,b,c,d are possible? (continue reading)
P.S. Well, I did calculations manually(didn't use any formula) and got 14 as the answer. However, it took around 10 minutes to do the lengthy steps. So, is there an easy way to do this?