Category : subsequence

Source Code of Problem C++ Code for finding subsequence of a given string. In this problem I have used recursion for solving this problem. I also get the correct approach of this problem and code it also. But now my code is not working. It is giving a runtime error when I input a string. ..

Read more

#include <bits/stdc++.h> using namespace std; void printSubsequence(string input, string output) { if (input.empty()) { cout << output << endl; return; } printSubsequence(input.substr(1), output + input[0]); printSubsequence(input.substr(1), output); } int main() { string output = ""; string input = "abcd"; printSubsequence(input, output); return 0; } Here, the function printSubsequence() is called twice in the function itself. ..

Read more