题目描述
Given a mathematical equation that contains only numbers and +, -, , /. Print the equation in reverse, such that the equation is reversed, but the numbers remain the same.
It is guaranteed that the given equation is valid, and there are no leading zeros.
Example 1:
Input:
S = "20-3+52"
Output: 25+3-20
Explanation: The equation is reversed with
numbers remaining the same.
Example 2:
Input:
S = "5+256-2/4"
Output: 4/2-562+5
Explanation: The equation is reversed with
numbers remaining the same.
Your Task:
You don't need to read input or print anything. Your task is to complete the function reverseEqn() which takes the string S representing the equation as input and returns the resultant string representing the equation in reverse.
Expected Time Complexity: O(|S|).
Expected Auxiliary Space: O(|S|).
Constraints:
1<=|S|<=10^{5}
The string contains only the characters '0' - '9', '+', '-', '', and '/'.
输入格式
见题面
输出格式
见题面