Find it runtime error

https://ide.codingblocks.com/s/187977 please check what’s wrong with this code why it’s giving runtime error

Hey @jaiskid,
There is a segmentation fault in your code because of the 9th line, where you’re trying to memset zero to the memory allocated to ans,
i.e. memset(ans, 0, (max + 1) * sizeof(int));
Just comment this line and you’ll be good to go.
(guess why? think in terms of global declaration of ans) :upside_down_face:

@Yashwardhan_Gautam yeah I have correct the code after analysing my mistake I have already submitted the code now I am going to mark it resolve or otherwise mark from your side

1 Like

okay @jaiskid,
That’ll be great, you can give rating too if you wish too. :slightly_smiling_face:

1 Like

Hey @jaiskid,
Just a humble reminder.
You can mark the doubt resolved.