Tallest dwarf : shouts “white” if no of whites in front of him are odd , shouts “black” if no of whites in front of him are even.

so now every dwarf notes this result (if the total no of whites except the last person are even or odd)

Now, n-1th dwarf counts the number of whites in front of him (let this be r)

if r is odd and the number of hats according to tallest are also odd…then he is wearing black.

if r is even and the number of hats according to tallest are also even…then he is wearing black

remaining cases its white…

Now, when this n-1th dwarf shouts out white => then all the other dwarves update their reading as odd from n-1th position if even from nth position(shouted by tallest) and vice versa…

and if he shouts out black then the readings are not updated…

…so similarly every dwarf calculates their hat color and only tallest one may die…so max is 1.