Help me with the code

I don’t know where I am wrong

Hi @sattyrajpoot39, you’re code is not correct. For the given problem the code is very simple but you’ve seen to make a complex code which is not at all required. Also you’re not using arrays properly here. Like you have created an arrray a1 of size n and then using a1[n]. You must know that indexing starts from 0 and hence we can use 0,1,2 … n-1 as indices but you have used a1[n].

I suggest you to read the arrays topic again and then attempt this question. Again this question is very simple and direct so next time try to make simple algorithm. Always try to make the simplest yet efficent algo/code to tackle any question.

Hope this helps :slight_smile:

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.