← All problemsSign in

365. Water and Jug Problem

LeetCodeMathDepth-First SearchBreadth-First SearchOpen on judge ↗

You are given two jugs with capacities x liters and y liters. You have an infinite water supply. 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. Example 1: Inpu

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start