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

Open every published interview problem, solution, scene, and memory room free, with no account.

More Stacks & Queues problems