Ai
1 Star 2 Fork 5

LilithSangreal/LeetCode-Solutions

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
reaching-points.cpp 440 Bytes
Copy Edit Raw Blame History
kamyu authored 2018-02-11 21:35 +08:00 . Create reaching-points.cpp
// Time: O(log(max(m, n)))
// Space: O(1)
class Solution {
public:
bool reachingPoints(int sx, int sy, int tx, int ty) {
while (tx >= sx && ty >= sy) {
if (tx < ty) {
swap(sx, sy);
swap(tx, ty);
}
if (ty > sy) {
tx %= ty;
} else {
return (tx - sx) % ty == 0;
}
}
return false;
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LilithSangreal/LeetCode-Solutions.git
git@gitee.com:LilithSangreal/LeetCode-Solutions.git
LilithSangreal
LeetCode-Solutions
LeetCode-Solutions
master

Search