Login

All Problems

Problem title

Difficulty

Avg time to solve

Ninja and Strings

Moderate

15 mins

Finding Binary In Decimal

Easy

15 mins

Reorder Edges

Moderate

30 mins

WRONG TURN

Moderate

15 mins

Remove All Nodes with Value K

Easy

10 mins

Invert a Binary Tree

Moderate

45 mins

Sort Array Of Strings

Easy

15 mins

Maximum Area of a Triangle

Easy

10 mins

Row Wave Form

Easy

15 mins

Zigzag Binary Tree Traversal

Easy

10 mins

Problem

Submissions

3

Avg. time to solve

15 min

Success Rate

85%

Problem Statement

```
[“a”], [“ab”], [“abc”], [“ac”], [“b”], [“bc”], [“c”]
```

```
The first line of input contains an integer 'T' which denotes the number of test cases or queries to be run. Then the test cases follow.
The first and the only line of each test case contains a string ‘STR’.
```

```
For each test case, print all the possible subsequences of the given string ‘STR’ in lexicographically sorted order.
Print the output of each test case in a separate line.
```

```
You do not need to print anything; it has already been taken care of. Just implement the given function.
```

```
1 <= ‘T’ <= 100
1 <= |STR| <= 10
Where |STR| represents the length of ‘STR’.
Time Limit: 1 sec
```

```
2
aba
aaa
```

```
a a aa ab aba b ba
a a a aa aa aa aaa
```

```
For test case 1:
In this sample test case, the following are the possible subsequences of the given ‘STR’:
1. “a”
2. “b”
3. “a”
4. “ab”
5. “ba”
6. “aa”
7. “aba”
After arranging these subsequences into lexicographically sorted order, we get:
“a”, “a”, “aa”, “ab”, “aba”, “b”, “ba”
For test case 2:
In this sample test case, the following are the possible subsequences of the given ‘STR’:
1. “a”
2. “a”
3. “a”
4. “aa”
5. “aa”
6. “aa”
7. “aaa”
After arranging these subsequences into lexicographically sorted order, we get:
“a”, “a”, “a”, “aa”, ”aa”, “aa”, “aaa”
```

```
2
x
zxy
```

```
x
x xy y z zx zxy zy
```

```
For test case 1:
In this sample test case, there is only one possible subsequence of the given ‘STR’:
1. “x”
For test case 2:
In this sample test case, the following are the possible subsequences of the given ‘STR’:
1. “z”
2. “zx”
3. “zxy”
4. “x”
5. “xy”
6. “y”
7. “zy”
After arranging these subsequences into lexicographically sorted order, we get:
“x”, “xy”, “y”, “z”, “zx”, “zxy”, “zy”
```

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Language

Change Theme

Solution submission not allowed

Save Code

Reset Code