Problem · String
Permutations of Unique Characters
Learn this problemProblem statement
Given a non-empty string word whose characters are all distinct, return every permutation of its characters.
Return the permutations in lexicographic order.
Function
generatePermutations(word: String) → String[]Examples
Example 1
word = "abc"return = ["abc","acb","bac","bca","cab","cba"]There are 3! = 6 permutations, listed lexicographically.
Example 2
word = "z"return = ["z"]A one-character word has exactly one permutation.
Constraints
1 <= word.length <= 9wordcontains distinct lowercase English letters.