Whats wrong in my code

Problem Link link
Solution Link link
Editorial Link link
My logic and code are both similar to the ones in the Editorial, but still I am getting a WA. Where am I wrong?
Are there any corner cases?