Challenge: Prefix to Postfix Conversion

Convert a prefix expression to a postfix expression.

Problem statement

In this challenge, write a function postfix(prefix) that takes a prefix expression as prefix, converts it to a postfix expression using a stack, and then returns it.

  • Prefix expression: An expression in which the operator appears before the operands.

  • Postfix expression: An expression in which the operator appears after the operands.

For example, if we have an expression A+BA+B, then its prefix expression would be +AB+AB, and its postfix expression would be AB+AB+.

Get hands-on with 1200+ tech skills courses.