Can you tell me where i am getting wrong??
The subset sum to target
#include<bits/stdc++.h> using namespace std; int main() { int n,sum; cin>>n>>sum; vector v; for(int i=0;i<n;i++){ int no; cin>>no; v.push_back(no); } sort(v.begin(),v.end()); if(v[0]>sum){ cout<<“No”<<endl; } else if(v[0]==sum){ cout<<“Yes”<<endl; } else{ int ans = 0; int flag = 0; for(int i=0;i<n;i++){ for(int j=i;j<n;j++){ ans += v[j]; if(ans == sum){ cout<<“Yes”<<endl; flag=1; break; } } if(flag==1){ break; } } if(flag==0){ cout<<“No”<<endl; } } return 0; }
hi @abhinavssr2003_eab0717682969e5c, send the code on ide.codingblocks.com
write save send he url of page
it is not saving the 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.