Runt time error

while submitting i am getting run time error in 4rth testcase where as others are being completed.

hey @Vasundhra-Bhardwaj-576869519460287, look over the constraints, they are very high. So make the array dynamically with size n+1.

i have done that …this time though still there is run time error with less time …

https://ide.codingblocks.com/s/103725 my code with correction …is this run time error there because i used pointers?

hey @Vasundhra-Bhardwaj-576869519460287, yes runtime error can also due accessing invalid memory location.

hey @Vasundhra-Bhardwaj-576869519460287, there is a case when n=100000 k=1000000000.
In such a case array approch is not working and giving runtime error.
Are you familiar with hashing data structure.

ah ohk …actually i know about it but …ryt now in my batch it hasnt been told yet …

hey @Vasundhra-Bhardwaj-576869519460287, than wait for hashing to be completed. With hashing it wont take such high time.

oh ohk then i’ll mark this question…thanks for help!

1 Like