This is our solution and implementation to problem #365: Water and Jug Problem on LeetCode.
Our code is written in Java. If you want to code your solution in a different language, no worries, as the core concepts will carry over from language to language. This page includes our analysis of the problem, our implementation strategy a breakdown on the space and time complexity, and the full code implementation.
If you would like to view the original problem and solve it, please visit: Water and Jug Problem on LeetCode.
Problem Analysis
.... Let's break down the procedure for the first example, where x=3, y=5, and z=4:
Full Code
Our solution is given in the Java code below:
All of our solutions are hosted on GitHub. The code on this page was pulled from the repo.