Hi,
I was trying to solve the Letter Stamper Problem that was asked in
codejam finals round.
I took this sample input : ABCACB.
I wrote a program and ran it and the output I got was 16 which is
contradictory from the output that the finalists got which was 14. Can
someone kindly explain the sequence for this. This is the
understanding and assumption of my sequence. Correct me if I am wrong.

Operation               Printed so far          Stack
0. -                    -                               -
1. Push A               -                               A
2. Print                A                               A
3. Push B               A                               AB
4. Print                AB                              AB
5. Push C               AB                              ABC
6. Print                ABC                             ABC
7. Pop          ABC                             AB
8. Pop          ABC                             A
9. Print                ABCA                    A
10. Push                ABCAC                   AC
11. Print               ABCAC                   AC
12. Push                ABCAC                   ACB
13. Print               ABCACB                  ACB
14. Pop         ABCAC                   AC
15. Pop         ABCAC                   A
16. Pop         ABCAC                   -

I looked many times and 16 is the answer I get. But I ran the same
input for the finalists's solution, but I got 14. Kindly correct me
where I have gone wrong.

Thanks,
Bragaadeesh.

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to