Leetcode 365 Solution
This article provides solution to leetcode question 365 (water-and-jug-problem)
Access this page by simply typing in "lcs 365" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/water-and-jug-problem
Solution
class Solution {
int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a % b);
}
public:
bool canMeasureWater(int x, int y, int z) {
return z == 0 || (x + y >= z && z % gcd(x, y) == 0);
}
};