Suppose you have a 3 liter jug and a 5 liter jug (this could also be in gallons). The jugs have no measurement lines on them either. How could you measure exactly 4 liter using only those jugs and as much extra water as you need?


This question was actually asked in a popular movie – Die Hard With A Vengeance.

Try figuring this one out on your own before reading the answer. It should be clear that the goal is to end up with 4 liter in the 5 liter jug, since having 4 liters in the 3 liter jug is impossible.

The answer, broken down in steps:

Step 1 : First, fill the 5 liter jug and then pour it into the 3 liter jug. The 5 liter jug now has only 2 liters left.

Step 2 : Next, empty out the 3 liter jug. Then, pour the 2 liters from the 5 liter jug to the 3 liter jug. So, now the 3 liter jug has 2 liters.

Step 3 : Fill the 5 liter jug again, and pour 1 liter into the 3 liter jug. Now, what’s left in the 5 liter jug? Well, exactly 4 liters! There’s your answer.

Hiring? Job Hunting? Post a JOB or your RESUME on our JOB BOARD >>

Subscribe to our newsletter for more free interview questions.

3,723 thoughts on “Measure 4 liters”

Fatal error: Call to undefined function twentyfifteen_comment_nav() in /home/programmerinterv/public_html/wp-content/themes/programmerinterview/comments.php on line 33