perfect answer
On Fri, Feb 21, 2014 at 12:40 AM, kumar raja rajkumar.cs...@gmail.comwrote:
Thanks for the solution. The idea worked for me.
On 21 February 2014 01:58, Shashwat Anand m...@shashwat.me wrote:
Think in binaries.
'1' = push, '0' = pop.
So a sequence of operations will
Hi all,
Here is a permuatation related question.
Suppose the set is {a,b,c};
At a given point of time either u can push an
elemnt on to the stack or pop of the element.
While pushing the elements u have to follow the
order a,b,c as given in the set.
When u pop the element u will print it to
Think in binaries.
'1' = push, '0' = pop.
So a sequence of operations will consist of 0's and 1s.
Say N = length of set.
Property 1: count of 0 = count of 1 = N.
There will be N push and N pop.
Property 2: At any point count of 1s = count of 0s.
1100 is valid. [2 push, 2 pop.]
1001
Thanks for the solution. The idea worked for me.
On 21 February 2014 01:58, Shashwat Anand m...@shashwat.me wrote:
Think in binaries.
'1' = push, '0' = pop.
So a sequence of operations will consist of 0's and 1s.
Say N = length of set.
Property 1: count of 0 = count of 1 = N.
There