Medium · Stacks & Queues

Prefix to Postfix

Given a string exp holding a valid prefix expression whose operands are single characters and whose operators are the binary +, -, * and / (spaces may appear and are ignored), return the same expression in postfix form without spaces.

Examples

Example 1

{
  "exp": "*-A/BC-DE"
}

Output: ABC/-DE-*

Example 2

{
  "exp": "+AB"
}

Output: AB+

Rebuild it in the studio

Core interview problems are free with a full runner and lessons; Pro opens the complete library.

More Stacks & Queues problems