i have a problem, that i don\'t know how to solve it.
i have a binary string and i want to generate all possible binary substrings.
Example :
This does it:
vector submasks(string in)
{
vector out;
out.push_back(string(in.size(), '0'));
for (int i = 0; i < in.size(); ++i)
{
if (in[i] == '0') continue;
int n = out.size();
for (int j = 0; j < n; ++j)
{
string s = out[j];
s[i] = '1';
out.push_back(s);
}
}
return out;
}
The algorithm does this:
I think that's pretty much optimal.