Permutations of Unique Characters
Updated
Problem 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.
More Salesforce Phone Screen questions
- Detect a Cycle in a Linked ListPHONE SCREEN · Seen Oct 2026
- Find Rows Common to Two TablesPHONE SCREEN · Seen Oct 2026
- Merge Two Sorted Linked ListsPHONE SCREEN · Seen Oct 2026
- Minimum Window of Required WordsPHONE SCREEN · Seen Aug 2026
- Minimum Window SubstringPHONE SCREEN · Seen Aug 2026
- Optimal Account BalancingPHONE SCREEN · Seen Jul 2026
- Longest Increasing SubsequencePHONE SCREEN · Seen Jul 2026
- Maximal SquarePHONE SCREEN · Seen Jul 2026
- ATM Queue Exit OrderPHONE SCREEN · Seen May 2026
- Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026
Similar questions at other companies
- All Rearrangements of a StringAdobe · PHONE SCREENAdobe interview questions
- DFS Subsequences of a String (For MLE)CoinDCX · PHONE SCREEN
- Expression Add OperatorsPinterest · PHONE SCREENPinterest interview questions
- Phone Keypad Letter CombinationsGoogle · ONSITE INTERVIEWGoogle interview questions
- Permutations of Character PositionsPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
- Generate Balanced ParenthesesInMobi · OAInMobi interview questions
- DFS Subsequences of a String (For MLE)Wayfair · OAWayfair interview questions
- Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
- Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
- Remove Parentheses from a Plus-Minus ExpressionOracle · PHONE SCREENOracle interview questions