Hi, I happened to solve this problem first on my own, but was not able to pass 3 test cases out of 4. When seeing the editorial, the code appears to be similar to what I had written. Please look into it.
Code Link : https://ide.codingblocks.com/s/213203