Distinct Letter Arrangements
Updated
Problem statement
A permutation of a string uses all of its letters in some order. When a letter repeats, different orders can spell the same word. For example, swapping the two ps in "apple" gives "apple" again.
Given a string s, return every different word you can spell with all of its letters. List each word once, with no duplicates, in alphabetical order.
Function
distinctPermutations(s: String) → String[]Examples
Example 1
s = "bob"return = ["bbo","bob","obb"]The letters are b, b, o. Swapping the two bs gives the same word, so there are only 3 different arrangements: "bbo", "bob" and "obb".
Example 2
s = "noon"return = ["nnoo","nono","noon","onno","onon","oonn"]Two ns and two os can be arranged in 6 different ways. In alphabetical order they are nnoo, nono, noon, onno, onon, oonn.
Example 3
s = "cat"return = ["act","atc","cat","cta","tac","tca"]All letters differ, so every one of the 3 * 2 * 1 = 6 orders is a different word.
Constraints
1 <= s.length <= 6scontains only lowercase English letters.
More DocuSign Phone Screen questions
- Symmetric Binary TreePHONE SCREEN · Seen Oct 2026
- Union Area of Two RectanglesPHONE SCREEN · Seen Oct 2026
- Execute Cursor-Based Text Editor OperationsPHONE SCREEN · Seen Sep 2026
- Minimize Array Sum After K Halving OperationsPHONE SCREEN · Seen Sep 2026
- Fizz and Buzz Words From 1 to nPHONE SCREEN · Seen Sep 2026
- Two Positions That Add Up to a TargetPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Rain Kept Between WallsPHONE SCREEN · Seen Mar 2026
- Exact Palindrome CheckPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
- Reverse the Characters of a TextPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2022
- Rebuild a Trip From Flight TicketsPHONE SCREEN · Seen Apr 2019
Similar questions at other companies
- Phone-Number Letter CombinationsHeadway · PHONE SCREENHeadway interview questions
- Letter Combinations of a Phone NumberLinkedIn · PHONE SCREENLinkedIn interview questions
- String Permutations in Custom Character OrderWex · OA · PHONE SCREEN
- Numeric Poker OperationsRippling · PHONE SCREENRippling interview questions
- Unique String PermutationsAmazon · PHONE SCREEN
- Restore Addresses with K SegmentsByteDance · PHONE SCREENByteDance interview questions
- Permutations of Unique CharactersSalesforce · PHONE SCREENSalesforce interview questions
- Count Prefix Paths in a Character GraphGoogle · PHONE SCREENGoogle interview questions
- Sorted Subsets of a StringMicrosoft · PHONE SCREENMicrosoft interview questions
- Maximum Unique Substring SplitThe Walt Disney Company · PHONE SCREENThe Walt Disney Company interview questions