Subsequences of String Problem Statement

You are provided with a string 'STR' that consists of lowercase English letters ranging from 'a' to 'z'. Your task is to determine all non-empty possible subsequences of the string 'STR'.

Explanation:

A subsequence of a string is derived by deleting zero or more characters from the string while maintaining the order of the remaining characters.

Input:

The first line of input consists of an integer 'T' representing the number of test cases. Each test case contains one line, which holds the string 'STR'.

Output:

For each test case, print the subsequences of the string 'STR' separated by space. Each test case's output must be printed on a separate line. The order of output subsequences can vary.

Example:

Input:
2
abc
ab
Output:
a ab ac abc b bc c
a ab b

Constraints:

  • 1 ≤ T ≤ 10
  • 1 ≤ |STR| ≤ 16
  • Where |STR| denotes the length of the string 'STR'.

Note:

You do not need to print anything; the output functionality is already handled. Only implement the function to generate the required subsequences.
Be the first one to answer
Add answer anonymously...
Quikr Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter