This is a very well known puzzle and there are many variations of this puzzle. I picked this one up from “Mathematical Circles” by Dmitri Fomin, Sergey Genkin and Ilia Itenberg, Chapter #8, Problem #8.
Three people – A, B and C – are sitting in a row in such a way that A sees B and C, B sees only C, and C sees nobody. They were shown 5 caps – 3 red and 2 white. They were blindfolded, and three caps were put on their heads. Then the blind folds were taken away and each of the people was asked if they could determine the color of their caps. After A, and then B, answered negatively, C replied affirmatively. How was that possible?