Water and Jug Problem
Medium · Math & Number Theory · about 15 minutes
Asked at Google, Microsoft, Amazon, Meta.
You have jugs with capacities x and y liters and unlimited water. You may fill a jug, empty a jug, or pour one into the other until one is full or the other empty. Return true if you can end up with exactly target liters in total across the two jugs.