My issue
how is this logic wrong for the 3rd test case…doesnt make sense
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
long int a,b,c=0,test;
cin>>test;
while(test--){
cin>>a>>b;
long arr[a];
bool d=false;
for(int i=0;i<a;i++){
cin>>arr[i];
c=c|arr[i];
}
for(int j=0;j<=b;j++){
if((c|j)==b){
cout<<j<<endl;
d=true;
break;
}
}
if(!d){
cout<<"-1"<<endl;
}
}
return 0;
}
Problem Link: Append for OR Practice Coding Problem - CodeChef