
Hourglass
Question: You are given two hourglasses. One measures 4 minutes and one measures 7 minutes. How would you measure exactly 9 minutes?
Answer: This question is similar to 4 Quarts of Water. With water, we were able to fill and pour out the pail multiple times. We can use the same logic and easily come up solutions which start measuring 9 minutes somewhere in the middle of the procedure but those will not be ideal. If possible, we want to measure the 9 minutes right from the start.
Step | Time | 4 minute timer | 7 minute timer |
1 | 0 min | Start | Start |
2 | 4 mins | Flip | 3 minutes left |
3 | 7 mins | 1 minute left | Flip |
4 | 8 mins | Stop | Flip (1 minute left) |
5 | 9 mins | Stop |
If you have any questions, please feel free to send me an email at [email protected]. If you have any interview questions which you feel would benefit others, I would love to hear about it.
If you're looking for some serious preparation for your interviews, I'd recommend this book written by a lead Google interviewer. It has 189 programming questions and solutions:

can u plz explain in clear ??
I have better solution:
1. Start 4, Start 7
2. Flip, 3 mins
3. 1min, Stop
4. flip
5. flip
(1 + 4 + 4 )
Nice!
I have been a reader for a long time, but am a first time commenter. I just wanted to say great post!