You are given a string representing a linear equation with one variable x, where the equation may contain '+', '-', numbers, and terms with x.
Your task is to determine the value of x that satisfies the equation.
The result must be returned as:
"x=#value" → if there is exactly one integer solution
"No solution" → if no value of x can satisfy the equation
"Infinite solutions" → if every value of x satisfies it
The equation will always follow the format:
<expression> = <expression>
Input: equation = "2x+4=10-x"
Output: "x=2"
Explanation:
Rearranging gives 3x = 6, so x = 2.
Input: equation = "5x-3=5x+8"
Output: "No solution"
Explanation:
Left and right differ by constant: -3 ≠ 8.
Input: equation = "3x+9=3x+9"
Output: "Infinite solutions"
Explanation:
Both sides are identical.
Accepted:
Submission: