Skip to content

Commit 2249d35

Browse files
committed
Update 780_Reaching_Points.java
1 parent 6a12b56 commit 2249d35

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Math/780_Reaching_Points.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
class Solution {
22
public boolean reachingPoints(int sx, int sy, int tx, int ty) {
3-
while (sx < tx && sy < ty) {
4-
if (tx > ty) {
5-
tx %= ty;
6-
} else {
7-
ty %= tx;
8-
}
3+
if (tx < sx || ty < sy) {
4+
return false;
95
}
106

11-
if (sx == tx && sy <= ty && (ty - sy) % sx == 0) {
7+
if (sx == tx && (ty - sy) % sx == 0) {
128
return true;
139
}
14-
if (sy == ty && sx <= tx && (tx - sx) % sy == 0) {
10+
if (sy == ty && (tx - sx) % sy == 0) {
1511
return true;
1612
}
17-
return false;
13+
14+
return reachingPoints(sx, sy, tx % ty, ty % tx);
1815
}
1916
}

0 commit comments

Comments
 (0)