PROBLEM :https://leetcode.com/problems/target-sum/

Example >>5 1 1 1 1 1 3

output: 5.

//I just Memoized my recursive code but its giving Siggsev error . Recursive code was correct .

Please run on online compiler not on leetcode compiler as I have not used vectors as specified in question .I will change it later .

```
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
int dp[10001][10001];
int rec(int *arr ,int sum,int n)
{
if(n<0 || (sum!=0 && n==0))
{
return 0 ;
}
if(n==0 && sum==0)
{
return 1;
}
if(dp[sum][n]!= -1)
{
return dp[sum][n];
}
dp[sum][n]= rec(arr,sum-arr[n-1],n-1) + rec(arr,sum+arr[n-1],n-1);
return rec(arr,sum-arr[n-1],n-1) + rec(arr,sum+arr[n-1],n-1);
}
int main()
{
int n,sum;
for(int i=0;i<10001;i++)
{
for(int j=0;j<10001;j++)
{
dp[i][j]=-1;
}
}
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
cin>>sum;
cout<<rec(arr , sum, n);
}
```