***please check if question is complete***
lets see from D’s perspective – he/she is seeing 4 White caps
→ so if D is saying truth then A, B, C, E are wearing White caps and are saying truth but still B, C are seeing more than 1 Black caps.
→ so D must be lying → thus we can confirm D is wearing Black Cap
lets see from B’s perspective – he/she is seeing 4 Black caps
→ so if B is saying truth then A, C, D, E are wearing Black caps and B is wearing White cap.
→ but C is saying he’s seeing 1 White cap (B) and 3 Black caps (A, D, E) which is true according to B. So, C is saying truth even when wearing Black cap. This is contradiction so we can confirm B is wearing Black Cap
lets see from A’s perspective – he/she is seeing 3 White and 1 Black cap.
→ but we already know B and D are wearing Black caps → so A is lying and we can confirm A is wearing Black Cap
lets see from C’s perspective – he/she is seeing 1 White and 3 Black cap.
→ suppose C is saying truth then those 3 Black caps are A, B, D and white cap must be E
→ we can not prove that C is lying so we’ll consider he/she is saying truth and C is wearing White cap
White caps – C and E
Black Caps – A, B and D