Java solution passes test case


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

Log in to reply
 

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