Regarding the test cases

Sir can you provide me an idea why the test cases are coming wrong?

Hello @punetha.anmol001 you can see this:
i am giving you the code and the complete understanding of the approach .
you can check the dry run of the code:


if you have any doubt you can ask here:
Happy Learning!!

Sir can you once pick the error in my approach. I first calculated the frequency of the max count. and then just added the key to it.

Hello @punetha.anmol001 i thought you want approach that is why i gave you that :
but i have seen your code just now which means that your code is not optimised.
so even after correction for some cases it will still give TLE so that means that you have to change your approach.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.