String Max frequency working in compiler but showing test cases wrong

i have made slight changes in your code
now its working perfectly fine