Unlock hashing getting wrong answer

I am getting WA but it is correct for given test case
please check

Dry run and check for this case:
8 4
2 6 7 3 9 3 1 5

Expected output:
9 7 6 5 2 3 1 3

But your code is giving segmentation fault.
Also watch the hint video and verify the approach.

I am getting WA but it is correct for given test case please check https://ide.codingblocks.com/s/255203

i have watched the hint video

pls rectify my mistakes