There is a much optimised solution to this

step 1: fill 11 min hour glass with hand and immediately transfer to 7 min hour glass .
now 11 min hour glass contains sand approximate to 4 min .
step 2: throw the sand of 7 min hour glass and transfer those equivalent 4 min sand to 7 min hour glass.
step 3: fill 11 min hour glass again and let it get emptied and once it get empties , immediately start 7 min hour glass which contains sand of equivalent 4 min ( transferred from 11 min hour glass) .

@Rahulkr102 okay cool

Is my solution correct ?

how you can say it reserves memory statically , we are providing “n” a runtime only. so obviously it is done dynamically

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.