http://www.codechef.com/viewsolution/4367555
I am putting 101 or 010 in the stack. first element is put simply. But before putting the second element it checks whether it is same as the first one or not.Each time if filling gets failed I empty the stack and start filling it again.this is happening simultaneously with the input. at the end if the stack is full, that is it has 3 elements, answer is GOOD else BAD! Can anyone please help me with this…