Medium · Backtracking

Permutations (string)

Given a string s of distinct lowercase letters, return all of its permutations, i.e. every string that uses each character of s exactly once (s! strings), in any order.

Examples

Example 1

s="abc"

Output: 6 perms

Example 2

s="ab"

Output: 2 perms

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Backtracking problems