@@ -0,0 +1,645 @@
+/*%0AIf a or b is negative this means we are emptying a jug of x or y gallons respectively.%0A%0ASimilarly if a or b is positive this means we are filling a jug of x or y gallons respectively.%0A%0Ax = 4, y = 6, z = 8.%0A%0AGCD(4, 6) = 2%0A%0A8 is multiple of 2%0A%0Aso this input is valid and we have:%0A%0A-1 * 4 + 6 * 2 = 8%0A*/%0A%0A%0A%0Apublic class Solution%7B%0A%09public boolean canMeasureWater(int x, int y,int z)%7B%0A%09%09if(x+y%3Cz)%7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%09if(x == z %7C%7C y == z %7C%7C x+y == z) return true;%0A%09%09return z%25GCD(x, y) == 0;%0A%09%7D%0A%0A%09public int GCD(int a, int b)%7B            find greatest common divisor%0A%09%09while(b!= 0)%7B%0A%09%09%09int temp = b;%0A%09%09%09b = a%25b;%0A%09%09%09a = temp;%0A%09%09%7D%0A%09%09return a;%0A%09%7D%0A%7D

A math question find GCD