https://ide.codingblocks.com/s/187977 please check what’s wrong with this code why it’s giving runtime error
Find it 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)
@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