PS: Edited OP and added examples. Please check accordingly.
@l_returns I understood what you said, but I’m not sure if you are getting the question correct. I’m editing the OP to make the question more clear. Also, I have written down the code snippet based on your answer, but I’m not able to figure out how this will get me the desired result.
Also you mention MSB to be the right most one, but LSB is the right most one. MSB is the left most one.
using namespace std;
bool isLsbOne(int n)
if (n & 1)
vector<int> retOddArray(vector<int> &a)
for (int i=0; i<a.size(); i++)
b.push_back(a[i] >> 1);
a[i] >>= 1;
if (b.size() >= 4)
int n, input;
for (int i=0; i<n; i++)
vector<int> a = retOddArray(v);
sort(a.begin(), a.end(), greater<int>());
int b = a & a & a & a;