Distinct Characters Problem Statement

Given a string STR, return all possible non-empty subsequences with distinct characters. The order of the strings returned is not important.

Example:

Input:
STR = "cbc"
Output:
["c", "bc", "c", "cb", "b"]
Explanation:

The subsequences with distinct characters derived from "cbc" are "c", "bc", "c", "cb", and "b".

Constraints:

  • 1 <= T <= 100
  • 1 <= |STR| <= 15
  • Characters in STR are only lowercase English alphabets.

Input:

The input begins with an integer 'T', the number of test cases.
Each test case contains a single string STR.

Output:

For each test case, output the distinct character subsequences on a new line.
Note:
If the same string can be generated multiple times, include each occurrence. You are not required to print anything; simply implement the function to achieve the desired results.
Be the first one to answer
Add answer anonymously...
Think Future Technologies 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