Skip to content

Instantly share code, notes, and snippets.

@run
Created October 28, 2014 01:33
Show Gist options
  • Save run/0db5a378c7a04196c2c0 to your computer and use it in GitHub Desktop.
Save run/0db5a378c7a04196c2c0 to your computer and use it in GitHub Desktop.
IP
void dfs(int start, int count, string &s,
vector<string> &tmp, vector<vector<string> > &result)
{
if (start == s.size() && count == 0) {
result.push_back(tmp);
return ;
}
for (int i = start; i < s.size(); i++) {
tmp.push_back(s.substr(start, i-start+1));
dfs(i+1, count-1, s, tmp, result);
tmp.pop_back();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment