My condition of letter already existed is not satisfied.plz give me the solution

@garganshul151 hey anshul your code is not working properly on the large test set
check on this input
aaaaaaaaaaaaaaagggxsxssyyyyyoooooooooolllllwwqwdeddddddddkjjjoooooooooooooooooooo
your output is
a15g3x2s3x1s2y5o30l5w3q1w1d9e1d8k1j3o20
but it should be
a15g3x1s1x1s2y5o10l5w2q1w1d1e1d8k1j3o20

so provide me the solution thats what i am asking

@garganshul151 hey anshul I made some changes in your code you can see
modified code.