Here is the problem:
Can anyone rectify my code? I am getting an NZEC however I have tried all the testcases(available along with the problem and a few mentioned in the comments) with correct outputs. If my code looks extremely complicated and confusing,well I’m sorry for that.
Here is my work: