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

Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.

More Stacks & Queues problems