water_and_a_jug_problem.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:algorithms 作者: anirudhpillai 项目源码 文件源码
def canMeasureWater(self, x, y, z):
        """
        :type x: int
        :type y: int
        :type z: int
        :rtype: bool
        """
        if x + y < z:
            return False
        if z <= 0 or x == z or y == z or x + y == z:
            return True
        return z % gcd(x, y) == 0


# Can also be done using bfs but that's slower
# https://discuss.leetcode.com/topic/50425/breadth-first-search-with-explanation/2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号