365-Water-And-Jug-Problem

Sat 17 May 2025

https://leetcode.com/problems/water-and-jug-problem

import pyutil as pyu
pyu.get_local_pyinfo()
print(pyu.ps2("python-dotenv"))
from typing import List
class Solution:
  def canMeasureWater(self, jug1Capacity: int, jug2Capacity: int, targetCapacity: int) -> bool:
    return targetCapacity == 0 or \
        jug1Capacity + jug2Capacity >= targetCapacity and \
        targetCapacity % gcd(jug1Capacity, jug2Capacity) == 0
new Solution().canMeasureWater()

Score: 5

Category: leetcode