The code is running fine for the given input ab but while submitting on hacker blocks, the test case is not being passed.
Question https://hack.codingblocks.com/contests/c/925/73
Code https://ide.codingblocks.com/s/116064
Recursion-All Subsequences
Ratul can you tell the exact problem name also, I am unable to open the contest link. plz share the exact words of sample input and output as given. I will see your code then,
Here is the question
RECURSION - ALL SUBSEQUENCES
Print all the subsequences of a string in lexicographical order.
Input Format:
First line contains an integer N, the no of strings.
Next, N lines follows one string per line.
Constraints:
1 < len(str) < 20
Output Format:
No of subsequences one per line
Sample Input:
1
ab
Sample Output:
a
ab
b
Explanation:
4 subsequences are printed.
Empty string is a subsequence.
Your code is not giving the null string as output. Plz Use map to store the outputs and finally print the values. You can use similar approach like this :
if(s[i]==ā\0ā){
out[j]=ā\0ā;
string temp=out;
m[temp]=temp;
Instead of using map Iām using 2-D array ch to store the subsequences and it is storing null string too at the end.
Here is the code
https://ide.codingblocks.com/s/116064
Ratul, I have made necessary changes in your code, I have used a vector of strings, to store the values and then I have used the sort function to sort the vector.
can you please share it once more it is not showing anything ?