1
/**
2
* @param {number} sx
3
* @param {number} sy
4
* @param {number} tx
5
* @param {number} ty
6
* @return {boolean}
7
*/
8
var reachingPoints = function (sx, sy, tx, ty) {
9
while (tx >= sx && ty >= sy) {
10
if (tx == ty) break;
11

12
if (tx > ty) {
13
if (ty > sy) tx %= ty;
14
else return (tx - sx) % ty == 0;
15
} else {
16
if (tx > sx) ty %= tx;
17
else return (ty - sy) % tx == 0;
18
}
19
}
20

21
return tx == sx && ty == sy;
22
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0