This is a problem whose soltution lies in Catalan number.In this case for any permutation no of pushes >= no of pops for any prefix of permutaion
So 5th Catalan no is given by : 2nCn / (n+1)
= 10C5 / 6
Hence the answer to this question should be 42.
Plz refer to the link :
Try to do with 3 numbers .
The number of permutation is equal to no. of post-order of binary search tree . since with 3 nodes number of binary search tree are 2nCn / (n+1) .
X->YZ , Y->XZ , ...