In the land of Geopolizza, three men were captured by the infamous monster, The riddler. So, the riddler buries the three men, named 1, 2 and 3 in such a manner, that 1 is in the front, 2 in the middle and 3 in the back. They are buried neck deep, and cannot move, not even their heads. He shows them 5 caps, two of which are red and 3 of them are white. He then switches off the lights and places a hat on top of their heads. The situation is such that no one can see their hat color, 1 is facing the wall and cant say anything, 2 can see 1 and 3 can see both 1 and 2. Then he tells the rules of his game: "If either of you three can tell the correct color of your head, I will let all of you go. However, if any of you answer wrong, all 3 of you will instantly die. Time is 3 minutes."
Upon 2 and half minutes passing, A shouts the answer and all 3 are released free. How did he know the correct answer ?

Man 1 is wearing white. He arrives at the conclusion as follows:
From the fact that neither 2 nor 3 gives the answer, 1 concludes that both these men have insufficient information to determine the color of their hats.
Man 3 must be seeing at least one white hat on the heads of 1 and 2 (if he would see two black hats, he would know that he is wearing a white hat). Further, Man 2 therefore knows that he and/or A is wearing a white hat. Since he cannot give an answer, he must be seeing a white hat on 1st head (if 2 would see 1 wearing a black hat, he would know that he himself wears a white one). From the fact that neither 2 nor 3 can give an answer to the riddler question, 1 finally concludes that he is wearing a white hat! He thus shouts the correct answer and all 3 of them are released. Yay.