题目描述
You are given a string that represents the postfix form of a valid mathematical expression. Convert it to its prefix form.
Example:
Input:
ABC/-AK/L-
Output:
-A/BC-/AKL
Explanation:
The above output is its valid prefix form.
Your Task:
Complete the function string postToPre(string post_exp), which takes a postfix string as input and returns its prefix form.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
Constraints:
3<=post_exp.length()<=1000
输入格式
见题面
输出格式
见题面
样例输入
ABC/-AK/L-*
样例输出
*-A/BC-/AKL