You are viewing a single comment's thread. Return to all comments →
The strange thing is that I uploaded the same solution in C#, C++ and Java 8 and for all of them "Test case #4" fails with a run time error.
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.