RE in HRDSEQ

I am facing this Error SIGSEGV and crawled the web for solution but not found any successful solution (I have tried even reducing the array to 1 but it didn’t work). Please tell me how to get rid of it.
https://www.codechef.com/viewsolution/29570346
Problem: HRDSEQ

Might be also because you declared n=0 twice, in line 30 and line 5, and in the if statemnts several times.

One immediate Problem: N can be as high as 128, so:

int A[128], ...

coupled with:

            if(A[i]==A[N])

is an out-of-bounds access.

1 Like