Java 0 ms solution by finding GCD

  • -1
    public boolean canMeasureWater(int x, int y, int z) {
            if(z>y && z>x)return false;
            if(z%gcd(x,y)==0)return true;
            return false;
        public int gcd(int x,int y){
            if(y==0)return x;
            return gcd(y,x%y);

Log in to reply

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