Two lines Java math solution.


  • 0
    C
    public class Solution {
        private int gcd(int x, int y) {return x>y?gcd(y,x):x==0?y:gcd(y%x, x);}
        public boolean canMeasureWater(int x, int y, int z) {return x+y+z==0 || (z<=x+y && z%gcd(x,y)==0);}
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.