Skip to content

Commit 8e1b24f

Browse files
refactor 365
1 parent 5397824 commit 8e1b24f

File tree

1 file changed

+16
-15
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+16
-15
lines changed

src/main/java/com/fishercoder/solutions/_365.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,24 @@
2626
*/
2727
public class _365 {
2828

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;
3238
}
33-
if (x == z || y == z || x + y == z) {
34-
return true;
35-
}
36-
return z % gcd(x, y) == 0;
37-
}
3839

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;
4447
}
45-
return x;
4648
}
47-
4849
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy