Q). => Coding: #include<iostream> using namespace std; int subsetSum(int a[],int len){ int sum=0,maxSum=0; for(int i=1;i<=len;i++){ for(int j=0;j<=len-i;j++){ for(int k=0;k<i;k++){ sum=sum+a[j+k]; } if(sum>maxSum){ maxSum=sum; } sum=0; } } return maxSum; } int main(){ int n; cout<<"Enter the size of the array\n"; cin>>n; int a[n]; cout<<"Enter Array size : \n"; for(int i=0;i<n;i++){ cin>>a[i]; } int r=subsetSum(a,n); cout<<"result "<<r<<endl; } => Output:
=>Bitwise Queries => Coding #include<iostream> #include<vector> using namespace std; vector<int> myQuery(int N,vector<int> A,vector<vector<int>> queries){ vector<int> my; int fVal,X,Y,counter=0; for(int i=0;i<queries.size();i++){ X=queries[i][0]; for(int k=0;k<N;k++){ fVal=2*(A[k]|X)-(A[k]^X); Y=queries[i][1]; if(fVal>=Y){ counter++; } } my.push_back(counter); counter=0; } cout<<"\n**Result***\n\n"; return my; } int main(){ int n,q,val,qVal; cout<<"Enter the size of the array :"; cin>>n; vector<int> arr; for(int i=0;i<n;i++){ cin>>val; arr.push_back(val); } cout<<"Enter the size of the query :"; cin>>q; vector<vector<int>> query; for(int i=0;i<q;i++){ vector<int