# Why does my code give WA? (CHEALG)

``````for _ in range(int(input())):
uncompressed_string = input()

letters = set(uncompressed_string)

totalLengthofCompressedString = len(letters)

for letter in letters:
countOfEachLetter = uncompressed_string.count(letter)
totalLengthofCompressedString += len(str(countOfEachLetter))

if totalLengthofCompressedString < len(uncompressed_string):
print('YES')
else:
print('NO')``````

I am unable to understand your solution but can suggest you to how to approach the problem.
let l be the length of string i.e. |s|=l;
set ans=0;
now iterate through the string with a outer for loop…
now in loop you can put a condition while a[i]==a[i+1];
count++;
suppose you got a 10 times;
what you will be writing in compressed string is a10 which are three characters…
you know each letter will take one place … so ans++;
now for digit what you can do is…
ans+=log10(10);
ans++;
as log always find one digit less.
At the end what you can output ans.
THAT SUMS UP EXPLANATION … FIND THE BELOW ATTACHED CODE…
IF U FEEL UNCOMFORTABLE ANYWHERE I WILL BE MORE THAN HAPPY TO HELP.
https://www.codechef.com/viewsolution/28527385