Last active
October 21, 2021 10:13
-
-
Save pradhuman7d1/ebc315a34a77438ec7c3c1af0a3f3cb8 to your computer and use it in GitHub Desktop.
pepcoding.com 21/10/2021 printSubsequence
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
void printSS(string ques, string ans) { | |
if(ques.length() == 0) { // base case | |
cout << ans << endl; // printing ans string | |
return; | |
} | |
printSS(ques.substr(1), ans + ques[0]); //recursive call including first character in ans string | |
printSS(ques.substr(1), ans); //recursive call excluding first character in ans string | |
} | |
int main() { | |
string str; // string str declaration | |
cin >> str; // input | |
printSS(str, ""); // function call passing input string and an empty string for output. | |
} |
This file contains hidden or 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
#include <iostream> | |
using namespace std; | |
void printSS(string ques, string ans) { | |
// write your code here | |
} | |
int main() { | |
string str; // string str declaration | |
cin >> str; // input | |
printSS(str, ""); // function call passing input string and an empty string for output. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment