Skip to content

Commit 6a12b56

Browse files
committed
Add 780_Reaching_Points.java
1 parent 2fa55dc commit 6a12b56

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Math/780_Reaching_Points.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
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+
}
9+
}
10+
11+
if (sx == tx && sy <= ty && (ty - sy) % sx == 0) {
12+
return true;
13+
}
14+
if (sy == ty && sx <= tx && (tx - sx) % sy == 0) {
15+
return true;
16+
}
17+
return false;
18+
}
19+
}

0 commit comments

Comments
 (0)