#365

Water and Jug Problem

expert · 1010 · lc medium +32 · 45% accepted · 1,677 likes · top 28%

play →

Description

You are given two jugs with capacities x liters and y liters and unlimited water. Return whether the total amount of water in both jugs may reach target using the following operations:

- Fill either jug completely with water.

- Completely empty either jug.

- Pour water from one jug into another until the receiving jug is full, or the transferring jug is empty.

Code

1
2
3