Amazon interview question

topological sort, solving postfix expression