LeetCode
Water and Jug Problem
Click
here
for an explanation.