4-min and 7-min hourglasses to get 9 minutes

Recently got asked the above brainteaser question in an onsite.

It turned out to be a very classic question, even EY asked it:

Glassdoor has a good answer to it: https://www.glassdoor.com/Interview/You-have-one-4-min-hourglass-and-one-7-min-hourglass-How-can-you-time-9-minutes-exactly-QTN_127466.htm

“Start both timers, when the four minute timer is done, there will be 3 minutes of sand left in the top of the seven minute timer.

Restart the four minute timer, while letting the remaining (3 minutes) of sand to drop from the 7 minute timer. (this is your 1st 3 minutes of your nine minute measurement)

When the 7 minute timer is done the 4 minute timer will now have 3 minutes of sand in the bottom. Flip the 4 minute timer (when this runs it will be your second 3 minutes of time). At the same time flip the 7 minute timer.

When the 3 minutes of sand run on the 4 minute timer, restart the 7 minute timer by this time 3 minutes worth of sand will have gone to the bottom of the timer, resetting it will give you the last 3 minutes of sand for you last 3 minutes of time measuring the 9 nine minutes.”