The Water Jug Problem can be solved using the following steps:
1. Fill the 3-liter jug.
2. Pour the 3 liters from the 3-liter jug into the 5-liter jug.
3. Fill the 3-liter jug again.
4. Carefully pour the water from the 3-liter jug into the 5-liter jug, filling it to the top. There will be only 2 liters of space available in the 5-liter jug, so after doing this, you’ll have 1 liter left in the 3-liter jug.
5. Empty the 5-liter jug.
6. Pour the remaining 1 liter from the 3-liter jug into the 5-liter jug.
7. Fill the 3-liter jug again.
8. Pour the entire 3 liters from the 3-liter jug into the 5-liter jug which already contains 1 liter.
Now you have exactly 4 liters in the 5-liter jug:
1 L (from 3L jug) + 3 L (from full 3L jug) = 4 L