#K1481. Infix to Postfix Expression Conversion

    ID: 24217 Type: Default 1000ms 256MiB

Infix to Postfix Expression Conversion

Infix to Postfix Expression Conversion

This problem requires you to convert an arithmetic expression from infix notation to postfix notation. In infix notation, operators are written in-between operands (e.g., A + B), but in postfix notation, the operator follows the operands (e.g., A B +). The expression may contain uppercase English alphabet characters as operands and the operators +, -, *, /, as well as parentheses for grouping. Your task is to implement a function that reads an expression from standard input and converts it into its equivalent postfix representation.

Note: The resulting postfix expression should have its tokens (operands and operators) separated by a single space. Use the standard algorithm for converting infix expressions to postfix (also known as Reverse Polish Notation), taking into account the correct operator precedence:

  • \( +, - \) have lower precedence.
  • \( *, / \) have higher precedence.

There will be multiple test cases used to evaluate your solution.

inputFormat

The input consists of a single line representing an arithmetic expression in infix notation. The expression will contain only uppercase letters, the operators +, -, *, /, and parentheses.

outputFormat

Output a single line containing the equivalent postfix expression. The tokens in the output (operands and operators) must be separated by a single space.

## sample
A+B
A B +