Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

You are given an input string 'S'. Your task is to find and return all possible permutations of the input string.

```
1. The input string may contain the same characters, so there will also be the same permutations.
2. The order of permutation does not matter.
```

Detailed explanation

```
cba
```

```
abc
acb
bac
bca
cab
cba
```

```
All the possible permutations for string "cba" will be "abc", "acb", "bac", "bca", "cab" and "cba".
```

```
xyx
```

```
xyx
xxy
yxx
yxx
xyx
xxy
```

```
All the possible permutations for string "xyx" will be "xyx", "xxy", "yxx", "yxx", "xyx" and "xxy". Here, all three permutations "xyx", "yxx", "xxy" are repeating twice but we need to print all the possible permutations and hence we are printing them twice..
```