17 lines c++ solution


  • 0
    F
    class Solution {
    public:
        int gcd(int a, int b)
        {
            if(b == 0) return a;
            else return gcd(b,a%b);
         }    
        bool canMeasureWater(int x, int y, int z) {
            if(x+y < z)
                return false;
            if (z == 0)
                return true;
            if(z%(gcd(x,y)) == 0)
                return true;
            return false;
        }
    };

Log in to reply
 

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