I tried to solve the question by using the second better approach used in editorial but when I’m trying to run it, it’s giving an error - Segmentation fault. I checked my code twice and didn’t found a issue, what could be the problem?
Here’s the code: https://ide.codingblocks.com/s/594306