Created
October 27, 2014 23:54
-
-
Save run/fe97294df33b486546e0 to your computer and use it in GitHub Desktop.
DFS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void dfs(int start, string &s, | |
vector<string> &tmp, vector<vector<string> > &result) | |
{ | |
if (start == s.size()) { | |
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, s, tmp, result); | |
tmp.pop_back(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment