Need Help in SANSKAR

Hi,
i implemented editorial for SANSKAR problem still i am getting RE. This is my solution .Can any one please tell me where did i done wrong?

Edit :-
You are getting SIGSEGV
A SIGSEGV is an error(signal) caused by an invalid memory reference or a segmentation fault. You are probably trying to access an array element out of bounds or trying to use too much memory. Some of the other causes of a segmentation fault are : Using uninitialized pointers, dereference of NULL pointers, accessing memory that the program doesn’t own.

1 Like

Hey @prasadram126

Firstly @acodebreaker2 is correct that you are not returning 0 which should throw NZEC SO you must add return 0 to your code,

But i see your code is throwing SIGSEGV (you may read about SIGSEGV here) which may be due to an array element out of bounds or trying to use too much memory (seems to be happening in this case), btw I don’t know dp but what i can observe is you are initializing a 2-D array,

int dp[K][size];

where

size=pow(2,N);

But when i see the constraints Max N can be 21 and

pow(2,21)=2097152

and so Segmentation Fault is occurring, because as far i know we can initialize an array of 10^6 elements…!

EDIT:
You may check this stackoverflow link for SIGSEGV on storing large number in a 2D array!!

@ corrected

1 Like

Yes it’s correct .But my code is not working for at least sample test cases which are given in problem page.So can you please help me in according to logic which is implemented using Editorial. Thanks