Standard Bar Stack and Queues · Infix, Postfix, and Prefix O(n) · O(n)
A fleet of sensor controllers emits commands operator-first, but the diagnostics dashboard only accepts operator-last feeds. The translator walks the command string backwards, keeps partially assembled feed fragments on a rack, and on each operator concatenates the two rack-top fragments with the operator moved to the end.
Input: A string expression in valid prefix form with single alphanumeric operands.
Output: Return the equivalent postfix (Reverse Polish) expression as a string.
1 <= expression.length <= 10^5Operands are single letters or digitsThe expression is guaranteed to be a valid prefix expressionInput: {"expression":"*-A/BC-/AKL"}
Output: "ABC/-AK/L-*"
Each backward step relocates its operator to the tail of the two fragments it joins.
Input: {"expression":"+AB"}
Output: "AB+"
The two-operand minimal case: operands first, operator last.