I hope I never have to get this kind of problem in an interview. LIke ever. Honestly, unless you get this exact problem, I have a hard time envisioning regular MFE grads unless they are Gary Kasparov's nephew to get this problem right by solving it in his head on the first time hearing it. Unless he has a sheet of paper and a few minutes or more to work it out. (I needed way more than that).

Ok, to get the 99/100 certainty, every guy in front of the last guy in line has to know not only what he says but also if he lives or dies. (Assuming the warden does the execution by going up each prisoner starting from the back, putting a gun to his head, and if the guy says black or white and gets it wrong, he pulls the trigger).

So we'll use 10 prisoners instead of 100 to make it simple.

Let's say the warden puts on 5 white hats and 5 black hats randomly on the 10 prisoners.

The last guy starts first. He will say white if he counts even number of white hats in front of him and black if he counts odd number of white hats.

Prisoner number, the color of his hat, and what he says:

#10, W, says W

(after the last guy says "White", the other 9 guys in front realize the warden didn't kill him so they know that he counted an even number of white hats and said white, but was not executed so he himself has a white hat. ** Now they all know there are an odd number of white hats, so that must mean there must also be odd number of black hats**

#9, B, says B

(#9 counts even white hats in front and even black hats in front of him but knows #10 is white. So he must be black)

#8, B, says B

(#8 counts even white hats in front and odd black hats in front. But he knows #9 is black and #10 is white. So he knows he will be black because he adds up the three black hats he sees in front + 1 black hat called already + his own black hat = odd number of black hats)

#7, B, says B

(#7 knows there are 2 black hats and 1 white hat behind him. He counts even white hats and even black hats in front him. He know he must be black because he knows 2 black hats behind + 2 black hats in front + his own black hat = odd number of black hats

#6, W, says W

(#6 knows there are 3 black hats and 1 white hat behind him. He counts odd white hats and even black hats in front. He must be white because 1 white hat behind + 3 white hats in front + his own white hat = odd number of white hats)

#5, W, says W

(#5 knows there are 3 black hats and 2 white hats behind him. He counts even white and even black hats in front. He must be white because 2 white hats behind + 2 white hats in front + his own white hat = odd number of white hats)

#4, B, says B

(#4 knows there are 3 black hats and 3 white hats behind him. He counts even white and odd black in front. He must be black because 3 black hats behind + 1 black in front + his own black hat = odd number of black hats)

#3, W, says W

(#3 knows there are 4 black hats and 3 white hats behind him. he counts odd black and odd white in front. He must be white because 3 white behind + 1 white in front + his own white hat = odd number of white hats)

#2, B, says

(#2 know there are 4 black hats and 4 white hats behind him. He sees guy in front is white. He must be black because 4 black behind + his own black hat = odd number of black hats)

#1, W

(#1 knows there are 5 black hats behind him and 4 white hats. Duh. He must be white)

This problem will work according to whether or not the warden pulls the trigger on #10.

If he said White and he pulled the trigger, then they all know there are even number of white hats and there must be even number of black hats. If he said black and he pulled the trigger, then there are even number of white hats and even number of black hats. If he said black and he didn't pull trigger, then they all know there are odd number of white hats and odd number of black hats.

For 100 prisoners, it would be fair if the warden gave every guy a piece of paper and a pencil to keep track of the number of blacks or whites behind them.