Search⌘ K
AI Features

Print All Permutations of a String

Explore how to generate all possible permutations of a string by applying recursive strategies. Understand factorial computation for permutations and learn to implement solutions that consider each character as a starting element, leading to a complete set of string arrangements.

Statement

Given a string, print all possible permutations of the string.

Example

All permutations of string “bad” are:

foo a bad bda abd adb dab dba

Sample input

"bad"

Expected output

["bad", "bda", "abd", "adb", "dab", "dba"] 

Try it yourself

Note: The order in which the permutations are generated or returned does not affect the ...