File tree Expand file tree Collapse file tree 1 file changed +16
-15
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change 26
26
*/
27
27
public class _365 {
28
28
29
- public boolean canMeasureWater (int x , int y , int z ) {
30
- if (x + y < z ) {
31
- return false ;
29
+ public static class Solution1 {
30
+ public boolean canMeasureWater (int x , int y , int z ) {
31
+ if (x + y < z ) {
32
+ return false ;
33
+ }
34
+ if (x == z || y == z || x + y == z ) {
35
+ return true ;
36
+ }
37
+ return z % gcd (x , y ) == 0 ;
32
38
}
33
- if (x == z || y == z || x + y == z ) {
34
- return true ;
35
- }
36
- return z % gcd (x , y ) == 0 ;
37
- }
38
39
39
- int gcd (int x , int y ) {
40
- while (y != 0 ) {
41
- int temp = y ;
42
- y = x % y ;
43
- x = temp ;
40
+ int gcd (int x , int y ) {
41
+ while (y != 0 ) {
42
+ int temp = y ;
43
+ y = x % y ;
44
+ x = temp ;
45
+ }
46
+ return x ;
44
47
}
45
- return x ;
46
48
}
47
-
48
49
}
You can’t perform that action at this time.
0 commit comments