We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Bruce can do the following, fill jug a with 5 gallons.
a = 5, b = 0
Now, he can fill jug b with 3 gallons from jug a.
a = 2, b = 3
He can empty jug b and empty 2 gallons from jug a to jug b.
a = 0, b = 2
Now, he can fill jug a with 5 gallons and fill jug b with 1 gallon from jug a. This results in jug a containing exactly 4 gallons of water.
a = 5, b = 2
why he made it so complex, why not just pour 4 galon at the begin in a, then it is done,
a = 4, b =
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Die Hard 3
You are viewing a single comment's thread. Return to all comments →
I cannot understand the question,
why he made it so complex, why not just pour 4 galon at the begin in a, then it is done, a = 4, b =