Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions algorithms/strings/all_subsequences_of_string.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>

using namespace std;

//Print All Subsequences Of String
void printAllSubsequences(string &input, int i, string t){
// i to keep track of string indexes
if(i == input.length()){
cout<<t<<endl;
return;
}

//For element select it in out subsequence once and leave it out once
printAllSubsequences(input, i+1, t+input[i]);
printAllSubsequences(input, i+1, t);

}



int main(){
string input;
cout<<"Enter the string of which you want to find subsequences"<<endl;
cin >> input;

cout<<"Subsequences of string are: "<<endl;
printAllSubsequences(input, 0, "");

}