this is my code
Submission #11897474
#include <bits/stdc++.h>
using namespace std;
int cnt=0;
void printAllSubsetsRec(int arr[], int n, vector v,int sum,int i)
{
// If remaining sum is 0, then print all elements of current subset.
if (n == 0) {
//reverse(v.begin(),v.end());
if(sum==0 && v.size()!=0){
cnt++;
// for (auto x : v){
// cout << x << " ";
// }
// cout << endl;
return;
}
}
// If no remaining elements,
if (n == 0)
return;
// We consider two cases for every element.
// a) We do not include last element.
// b) We include last element in current subset.
printAllSubsetsRec(arr, n - 1, v, sum,i+1);
v.push_back(arr[i]);
printAllSubsetsRec(arr, n - 1, v, sum - arr[i],i+1);
}
// Driver code
int main(){
int t;
cin>>t;
while(t--){
int arr[100];
int n;
cin>>n;
for(int i=0;i<n;i++)
cin>>arr[i];
// int sum;
// cin>>sum;
vector<int>v;
printAllSubsetsRec(arr, n, v, 0,0);
if(cnt!=0){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
return 0;
}