3 water jug problem algorithm. Step 1: Fill the 5 liter jug -> (0, 5).

3 water jug problem algorithm. Our target amount d should be present in one jug only.