Prefix to Infix Conversion
Convert a prefix expression to infix notation using a stack.
Input format
A single line with a valid prefix expression using single-letter operands (a-z) and the operators + - * /. No spaces.
Output format
Print the fully parenthesized infix expression, e.g. *+ab c (prefix *+abc) becomes ((a+b)*c).
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
*+abcExpected output
((a+b)*c)Example 2
Input
+a*bcExpected output
(a+(b*c))