Successful solution of problem Compilers and parsers - http://www.codechef.com/MAY14/problems/COMPILER/