Testcase 1 getting runtime error


Please point out mistake in my code due to which I am getting runtime error

hey @ankush.bhardwaj0, increase the size of N, array has only 0,1,2 so make freq array should be of size 3 (to have index 0,1,2).
Moreover you using while loop inside the for loop, so it will not be in linear time but in O(n^2).
I have made changes to your code, you can check them here.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.