We are given that there are:
Black helmets = 3
Red helments = 2
Let us start from the guy at the back. The guy at the back can see the two helmets in front of him. If the two helmets in front of him are red, then he can certainly say that his helmet is black since there are only 2 red helmets. Since that is not the case, then therefore he can either be black or red. Therefore this also means that at least 1 of the 2 guys in front of him has black helmet.
Since the remaining two should have at least 1 black, therefore the middle guy can see that the helmet in front of him is not red (so 1st guy is black). Because if the guy in front of him is red, then he can know that he must be black since remember, at least one of the 2 front guys must be black, but the middle guy cannot say that. Therefore the 1st guy knows he has a black helmet.