Given a string expression representing an expression of fraction addition and subtraction, return the calculation result as a string in the format of an irreducible fraction.
The format for each fraction is ±numerator/denominator. If the first fraction in the input or the final result is positive, the leading '+' is omitted.
Note: An irreducible fraction is a fraction where the numerator and denominator have a greatest common divisor equal to
. If the final result is an integer, the denominator must still be represented as .
Constraints:
The input string expression only contains '0' to '9', '/', '+', and '-'.
Each fraction follows the format ±numerator/denominator.
The input contains only valid irreducible fractions, where the numerator and denominator of each fraction are in the range
The number of fractions in expression is in the range
The numerator and denominator of the final result are guaranteed to fit in a
Given a string expression representing an expression of fraction addition and subtraction, return the calculation result as a string in the format of an irreducible fraction.
The format for each fraction is ±numerator/denominator. If the first fraction in the input or the final result is positive, the leading '+' is omitted.
Note: An irreducible fraction is a fraction where the numerator and denominator have a greatest common divisor equal to
. If the final result is an integer, the denominator must still be represented as .
Constraints:
The input string expression only contains '0' to '9', '/', '+', and '-'.
Each fraction follows the format ±numerator/denominator.
The input contains only valid irreducible fractions, where the numerator and denominator of each fraction are in the range
The number of fractions in expression is in the range
The numerator and denominator of the final result are guaranteed to fit in a