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.

AnswerBot
4mo
Return all possible non-empty subsequences with distinct characters from a given string.
Iterate through all possible subsequences of the input string
Check for distinct characters in each subsequence
Re...read more
Help your peers!
Add answer anonymously...
Think Future Technologies Software Developer interview questions & answers
A Software Developer was asked Q. Can you provide an example of how to use pointers in C/C++ and discuss different...read more
A Software Developer was asked Q. Pair Sum Problem Statement You are given an integer array 'ARR' of size 'N' and ...read more
A Software Developer was asked Q. Distinct Characters Problem Statement Given a string STR, return all possible no...read more
Popular interview questions of Software Developer
A Software Developer was asked Q1. Can you provide an example of how to use pointers in C/C++ and discuss different...read more
A Software Developer was asked Q2. Pair Sum Problem Statement You are given an integer array 'ARR' of size 'N' and ...read more
A Software Developer was asked Q3. Distinct Characters Problem Statement Given a string STR, return all possible no...read more
>
Think Future Technologies Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

