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 stringSTR
.
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...
Top Think Future Technologies Software Developer interview questions & answers
Popular interview questions of Software Developer
>
Think Future Technologies Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
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
Get AmbitionBox app