Python solution gcd


  • 5
    H
    class Solution(object):
        def canMeasureWater(self, x, y, z):
            """
            :type x: int
            :type y: int
            :type z: int
            :rtype: bool
            """
            a,b=x,y
            while y:
                r=x%y
                x=y
                y=r
            return bool(not z or (x and z<=a+b and not z%x))

  • 0
    H

    No offense but, whoever voted me down, mind telling me why?


  • 2

    nice solution! several explanation might be helpful.


Log in to reply
 

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