Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save duyet/55c91420c9fafbf54691 to your computer and use it in GitHub Desktop.
Save duyet/55c91420c9fafbf54691 to your computer and use it in GitHub Desktop.
vector<string> answer;
void getStrings( string s, int digitsLeft )
{
if( digitsLeft == 0 ) // the length of string is n
answer.push_back( s );
else
{
getStrings( s + "0", digitsLeft - 1 );
getStrings( s + "1", digitsLeft - 1 );
}
}
getStrings( "", n ); // initial call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment