Solve the Equation
Solve a given equation and return the value of x in the form of a string "x=#value". The equation contains only +, - operations, the variable x, and its coefficient.
Return "No solution" if there is no solution for the equation, or "Infinite solutions" if there are infinite solutions for the equation.
If there is exactly one solution for the equation, the value of x is guaranteed to be an integer.
Example 1
Input
equation = "x+5-3+x=6+x-2"Output
"x=2"Solving the equation gives the single integer solution x = 2.
Example 2
Input
equation = "x=x"Output
"Infinite solutions"Both sides are identical, so every value of x satisfies the equation.
Constraints
- 3 <= equation.length <= 1000
- equation has exactly one '='.
- equation consists of integers with an absolute value in the range [0, 100] without any leading zeros, and the variable 'x'.
- The input is generated that if there is a single solution, it will be an integer.