{"id":"bfad041d-5164-4ffc-adea-b200ad711261","name":"Print Subsequence","description":"1. You are given a string str.\r\n2. Complete the body of printSS function - without changing signature - to calculate and print all subsequences of str.\r\nUse sample input and output to take idea about subsequences.\r\n\r\nNote -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.","inputFormat":"A string str","outputFormat":"Subsequences of str in order hinted by Sample output","constraints":"0 &lt;= str.length &lt;= 7","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid printSS(string ques, string ans){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n string str;\r\n cin >> str;\r\n printSS(str, \"\");\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n\r\n }\r\n\r\n public static void printSS(String str, String ans) {\r\n \r\n }\r\n\r\n}"},"python":{"code":"def printSS(ques, ans):\r\n # Write your code here\r\nques = input()\r\nprintSS(ques, \"\")"}},"points":10,"difficulty":"easy","sampleInput":"yvTA","sampleOutput":"yvTA\r\nyvT\r\nyvA\r\nyv\r\nyTA\r\nyT\r\nyA\r\ny\r\nvTA\r\nvT\r\nvA\r\nv\r\nTA\r\nT\r\nA","questionVideo":"https://www.youtube.com/embed/Ke8TPhHdHMw","hints":[],"associated":[{"id":"22c902ff-9fff-4b5b-8227-74dd7dab2874","name":"(Print SubSequence)for a string of length 3 what is total no of subsequences","slug":"print-subsequence-for-a-string-of-length-3-what-is-total-no-of-subsequences","type":4},{"id":"4b4b98c7-4e08-4e47-85aa-95f12ebe2ccf","name":"(Print SubSequence)what if the string is palindrome?","slug":"print-subsequence-what-if-the-string-is-palindrome","type":4},{"id":"646f7138-21bd-4906-b2d5-e5972b6622a7","name":"(Print SubSequence) Revese of a string is a subsequnce of itslef?","slug":"print-subsequence-revese-of-a-string-is-a-subsequnce-of-itslef","type":4},{"id":"b8c2c32d-5d8c-4d28-a96b-5d0e9527b782","name":"(Print SubSequence) for the above problem what is the total no of non empty subsequences","slug":"print-subsequence-for-the-above-problem-what-is-the-total-no-of-non-empty-subsequences","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"d098699f-c1df-42c4-a81f-0cf54c32e7d7","name":"Print Subsequence","slug":"print-subsequence","type":1}],"next":{"id":"08238ac3-64eb-4a1d-8b02-733026bc2563","name":"Print Subsequence","type":3,"slug":"print-subsequence"},"prev":{"id":"bdaf583e-a53c-49a6-81f2-52fc05ce0352","name":"Get Maze Path With Jumps","type":3,"slug":"get-maze-path-with-jumps"}}}

Print Subsequence

1. You are given a string str. 2. Complete the body of printSS function - without changing signature - to calculate and print all subsequences of str. Use sample input and output to take idea about subsequences. Note -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.

{"id":"bfad041d-5164-4ffc-adea-b200ad711261","name":"Print Subsequence","description":"1. You are given a string str.\r\n2. Complete the body of printSS function - without changing signature - to calculate and print all subsequences of str.\r\nUse sample input and output to take idea about subsequences.\r\n\r\nNote -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.","inputFormat":"A string str","outputFormat":"Subsequences of str in order hinted by Sample output","constraints":"0 &lt;= str.length &lt;= 7","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nvoid printSS(string ques, string ans){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n string str;\r\n cin >> str;\r\n printSS(str, \"\");\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n\r\n }\r\n\r\n public static void printSS(String str, String ans) {\r\n \r\n }\r\n\r\n}"},"python":{"code":"def printSS(ques, ans):\r\n # Write your code here\r\nques = input()\r\nprintSS(ques, \"\")"}},"points":10,"difficulty":"easy","sampleInput":"yvTA","sampleOutput":"yvTA\r\nyvT\r\nyvA\r\nyv\r\nyTA\r\nyT\r\nyA\r\ny\r\nvTA\r\nvT\r\nvA\r\nv\r\nTA\r\nT\r\nA","questionVideo":"https://www.youtube.com/embed/Ke8TPhHdHMw","hints":[],"associated":[{"id":"22c902ff-9fff-4b5b-8227-74dd7dab2874","name":"(Print SubSequence)for a string of length 3 what is total no of subsequences","slug":"print-subsequence-for-a-string-of-length-3-what-is-total-no-of-subsequences","type":4},{"id":"4b4b98c7-4e08-4e47-85aa-95f12ebe2ccf","name":"(Print SubSequence)what if the string is palindrome?","slug":"print-subsequence-what-if-the-string-is-palindrome","type":4},{"id":"646f7138-21bd-4906-b2d5-e5972b6622a7","name":"(Print SubSequence) Revese of a string is a subsequnce of itslef?","slug":"print-subsequence-revese-of-a-string-is-a-subsequnce-of-itslef","type":4},{"id":"b8c2c32d-5d8c-4d28-a96b-5d0e9527b782","name":"(Print SubSequence) for the above problem what is the total no of non empty subsequences","slug":"print-subsequence-for-the-above-problem-what-is-the-total-no-of-non-empty-subsequences","type":4}],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"d098699f-c1df-42c4-a81f-0cf54c32e7d7","name":"Print Subsequence","slug":"print-subsequence","type":1}],"next":{"id":"08238ac3-64eb-4a1d-8b02-733026bc2563","name":"Print Subsequence","type":3,"slug":"print-subsequence"},"prev":{"id":"bdaf583e-a53c-49a6-81f2-52fc05ce0352","name":"Get Maze Path With Jumps","type":3,"slug":"get-maze-path-with-jumps"}}}
plane

Editor


Loading...

Print Subsequence

easy

1. You are given a string str. 2. Complete the body of printSS function - without changing signature - to calculate and print all subsequences of str. Use sample input and output to take idea about subsequences. Note -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.

Constraints

0 <= str.length <= 7

Format

Input

A string str

Output

Subsequences of str in order hinted by Sample output

Example

Sample Input

yvTA

Sample Output

yvTA yvT yvA yv yTA yT yA y vTA vT vA v TA T A

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode