As an example of input that gives a wrong answer:
CHHCHEFEF
should give answer of 2; your code reports 1.
Thnanks…i was unable to find out.
This means I need to change the whole logic???right?
Yes, probably you do need to change your method.