Only one testcase passed

#include<bits/stdc++.h>
using namespace std;

bool ans(int n,int sum,vector&arr){
if(n==0 && sum!=0){
return false;
}
unordered_sets;
int currsum = 0;
for(int i=0;i<n;i++){
currsum = currsum + arr[i];

	if(currsum==sum){
		return true;
	}
	if(s.find(currsum-sum)!=s.end()){
		return true;
	}
	s.insert(currsum);
}

return false;

}
int main() {
int n;
cin>>n;
int sum;
cin>>sum;
vectorarr;
for(int i=0;i<n;i++){
int x;
arr.push_back(x);
}

if(ans(n,sum,arr)==true){
	cout << "Yes" << endl;
}else{
	cout<< "No" << endl;
}

}

@Mohitpandey29
Hello Mohit,
your apporach is not correct u are considering subbarrays only to make target sum but it is also possible that some subsequence can sum up to form target
for example
{ 1,33,2 } ,target=3
here {1,2} is equal to target

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.