Algorithm · Airbnb · Medium
You are given two water containers with unequal maximum volumes, along with a desired amount of water. Both containers begin empty. On each move, you may do one of the following: Fill either jug to its full capacity. Drain either jug completely. Transfer water from one jug into the other, stopping once the source jug has no water left or the receiving jug cannot hold any more. Find the fewest moves needed to obtain the target amount, and return the operations in that…
Checking your access…