Your code is incomplete, but:
Here, you are counting all 'x' and all 'y' in the string, which is wrong.
Your requirement is:
Quote:You can select a substring with all equal characters and delete them and you will get the score i.e A[len] if len is the length of the substring deteted
^^^^ this is the substring of maximum length with all equal chars
You have to search where is that substring.