Skip to content

Instantly share code, notes, and snippets.

@pradhuman7d1
Last active October 21, 2021 10:13
Show Gist options
  • Save pradhuman7d1/ebc315a34a77438ec7c3c1af0a3f3cb8 to your computer and use it in GitHub Desktop.
Save pradhuman7d1/ebc315a34a77438ec7c3c1af0a3f3cb8 to your computer and use it in GitHub Desktop.
pepcoding.com 21/10/2021 printSubsequence
#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.
}
#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