Not accepting the right Code

I wrote the right code as taught earlier. But it didn’t work. After trying a lot I opened the editorial and it also had the same code. But even after trying that code it’s showing 3 test cases failed. Please look into it.

Hi @srivastavashivansh28_cebc0904d1f3e633,

   for(int i=0;i<=n;i++){
         cin>>arr[i];
    } 
  1. In the above code, you need to iterate from 0 to n-1.

targetSum(arr,n,n);

  1. Target should be equal to x.

Your Updated code,

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.