Why my code is not running

i have shared my link for this code below please check why it is not running

Hi @Gaurav_dev, since n can be as large as 10^5 but you have declared your array of the size 1000 which causes wrong ans due to accessing undefined memory so just increase the size of your array to 10^5

Here I have corrected your code :-

In case of any doubt feel free to ask :slight_smile:
If you got the answer then mark your doubt as resolved

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.