The second test case shows run time error

hey Anikash, you are getting runtime error because you accesing the invalid index of count array.

for testcase 1: range=4, so count array will be of range+1 i.e. 5 only. But your running loop(line 45) from 0 to n i.e. 6 times. You cannot update array 6 times if only 5 spaces are reserved for it. Thatswhy you are getting this error.

I am able to pass the 1st test case.
It has to be upto n, otherwise count[prefixArray[i]] won’t take the last element

hey Anikash, you are getting runtime error only beacuse your prefix[i] is going out of range.
just add this line(prefixArray[i]=(prefixArray[i]+n)%n;) after line no 32 of your code and all your testcase will be passed.

hey Anikash, if your query is resolved. Please mark this doubt as resolved and rate me on the basis of your experience.
rating option will appear just below where you mark this doubt as resolved

I added your line but it shows wrong answer

hey akh, please share your updated code here. Let me debug it and share it with you

hey @Anikesh, I had made the change that I have suggested and change the datatype to Long long and it passing all the testcases.
consider this https://ide.codingblocks.com/s/78831