You are viewing a single comment's thread. Return to all comments →
I encountered the same problem. The test case 4 has k bigger than n, which causes segmentation error due to index out of bounds when you do n - k. Solved the problem by setting k = k % n when it is larger than n.
Thank you a lot. I was stuck in this test case.
I thought it was because of a very huge data set that could exceed maximum memory size.