There are 100 people standing in a single straight line, all facing forward. They cannot look back or around. They are wearing colored hats of different colors. What is the maximum number of people who can correctly guess their hat color?
💡 Model Answer
The optimal strategy allows 99 people to guess correctly. The person at the back of the line (who can see all others) announces the color of the hat they see on the frontmost person. This announcement encodes the parity (even or odd) of a particular color class. Each subsequent person keeps track of the parity of hats they have seen and the parity announced by the person behind them. When it is their turn, they can deduce their own hat color by comparing the expected parity with the observed parity. The last person (front of the line) can always deduce their hat color because all others have already spoken. Thus, 99 out of 100 can be guaranteed correct, while the first speaker may be wrong.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500