my code’s output matches sample output but still, it is marked wrong in test cases.
I have added some comments in my code to explain my approach. so please try to understand it and tell me how to correct it rather than giving me your solution.
link: