Not hard to know it is simply transform from in-order to post-order.
My
first idea is to build a tree from in-order string and then traverse the tree by
post-order - naive so slow.
Subtle stack manipulation solves it - stack only
for operators:
http://cs.nyu.edu/courses/Fall12/CSCI-GA.1133-002/notes/InfixToPostfixExamples.pdf
BTW, I love Ruby more.
SPOJ #4 Transform the Expression
原文:http://www.cnblogs.com/tonix/p/3537867.html