Distinct Characters
Given a string “STR”, you need to return all the possible non-empty subsequences with distinct characters. You can return the strings in any order.
Note:
If the same string can be generated multiple times, return them multiple times.
A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
For eg. Let the input string be 'cbc'. Then all the subsequences with distinct characters will be - ['c', 'bc', 'c', 'cb', 'b'].
Input Format:
The first line of input contains an integer ‘T’ denoting the number of test cases to run. Then the test case follows.
The first and the only line of each test case contains the string 'STR'.
Output Format :
For each test case, print all the substrings with distinct characters.
Output for each test case will be printed in a new line.
Note:
You do not need to print anything; it has already been taken care of. Just implement the given functions.
Constraints:
1 <= T <= 100
1 <= |STR| <= 15
Where |STR| denotes the length of “STR”
String “STR” will only consist of lowercase English Alphabets.
Time Limit: 1 sec
CodingNinjas
author
2y
Brute Force
We can generate all possible subsequences of the string, and for each subsequence check if it contains any character multiple times. If it doesn’t contain any character multiple times, appe...read more
Help your peers!
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