Generate All String Permutations - Coding Interview Question

preview_player
Показать описание
Write an algorithm that takes an input string like "abc", and prints out all possible permutations of the string. A permutation of a group of elements is one of the n! number possible arrangements the elements can take, where n is the number of elements in the range.

We'd expect the following to hold true:

```
const str = "abc"
permutations(str)
// abc
// acb
// bac
// bca
// cba
// cab
```

A hint here: break the problem down, and think about what steps are going to be repeated. How would we get from "abc" to "acb"?

#softwareengineering #algorithms #programming #code
Рекомендации по теме
Комментарии
Автор

Thank you! what is this algorithm callled?

ee