Genie and Hats

A bunch of men are on an island.
A genie comes down and gathers everyone together and places a magical hat on some people’s heads (i e , at least one person has a hat).

The hat is magical: it can be seen by other people, but not by the wearer of the hat himself. To remove the hat, those (and only those who have a hat) must dunk themselves underwater at exactly midnight. If there are n people and c hats, how long does it take the men to remove the hats?
The men cannot tell each other (in any way) that they have a hat.

Note: Genie does not tell how many hats she has put.
All the men are perfect logicians and know that each other are perfect logicians

Sign Up
to access hints and editorial solutions for Genie and Hats
4461 successful submissions.
Click here to start solving coding interview questions