File tree 1 file changed +0
-33
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +0
-33
lines changed Original file line number Diff line number Diff line change 1
1
package com .fishercoder .solutions ;
2
2
3
- /**
4
- * 640. Solve the Equation
5
- *
6
- * Solve a given equation and return the value of x in the form of string "x=#value".
7
- * The equation contains only '+', '-' operation, the variable x and its coefficient.
8
-
9
- If there is no solution for the equation, return "No solution".
10
-
11
- If there are infinite solutions for the equation, return "Infinite solutions".
12
-
13
- If there is exactly one solution for the equation, we ensure that the value of x is an integer.
14
-
15
- Example 1:
16
- Input: "x+5-3+x=6+x-2"
17
- Output: "x=2"
18
-
19
- Example 2:
20
- Input: "x=x"
21
- Output: "Infinite solutions"
22
-
23
- Example 3:
24
- Input: "2x=x"
25
- Output: "x=0"
26
-
27
- Example 4:
28
- Input: "2x+3x-6x=x+2"
29
- Output: "x=-1"
30
-
31
- Example 5:
32
- Input: "x=x+2"
33
- Output: "No solution"
34
-
35
- */
36
3
public class _640 {
37
4
public static class Solution1 {
38
5
/**
You can’t perform that action at this time.
0 commit comments