Can anyone help me to debug the code here? I spent whole day on this problem, but I am unable to get it right.
I am AWARE of it failing on some test cases, and I know what those test cases are. I specifically need help in debugging the code and correcting it. I used the approach described by @gkcs in his video editorial, but I think I messed up somewhere.
I would be grateful if anyone could help.