Generate All String Permutations
Updated
Problem statement
Given a string s whose characters are distinct lowercase English letters, return every permutation of its characters.
Return the permutations in lexicographic order.
Function
generatePermutations(s: String) → String[]Examples
Example 1
s = "abc"return = ["abc","acb","bac","bca","cab","cba"]All six arrangements of the three distinct characters are returned in lexicographic order.
Example 2
s = "ba"return = ["ab","ba"]The input order does not determine the output order; the two permutations are sorted lexicographically.
Example 3
s = "x"return = ["x"]A one-character string has exactly one permutation.
Constraints
1 <= s.length <= 8scontains distinct lowercase English letters.
More Bloomberg LP Phone Screen questions
- N-ary Index-Path Encoder and DecoderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Word SearchOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Fewest Coins CombinationPHONE SCREEN · Seen Nov 2026
- Recommend Films from Viewers Who Watched Everything You DidPHONE SCREEN · Seen Nov 2026
- Track New Values in Sorted OrderPHONE SCREEN · Seen Nov 2026
- Design Browser HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Mutable Stock Price Top KPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Sparse Vector and Matrix OperationsPHONE SCREEN · Seen Oct 2026
- Add Two Numbers IIPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- String Permutations in Custom Character OrderWex · OA · PHONE SCREEN
- Permutations IILinkedIn · PHONE SCREENLinkedIn interview questions
- Unique String PermutationsAmazon · PHONE SCREEN
- Sorted Subsets of a StringMicrosoft · PHONE SCREENMicrosoft interview questions
- Generate Strings of Length at Least ThreeMorgan Stanley · ONSITE INTERVIEWMorgan Stanley interview questions
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
- Merge Weekday and Time IntervalsNextdoor · PHONE SCREENNextdoor interview questions
- Top K Movies by Play Count from CSV DataTubi · PHONE SCREEN
- Group AnagramsWorkday · PHONE SCREEN
Bloomberg LP interview experiences
- Bloomberg AI-Assisted Coding Round, All Levels: 14 Experiences
- Bloomberg SWE Intern Interview Questions: 68 Questions
- Bloomberg Interview Questions, Level Not Reported: 65 Questions
- Bloomberg Experienced Design & More: 126 Questions (Part 2 of 2)
- Bloomberg Experienced SWE Interviews: 167 Questions (Part 1 of 2)
- Bloomberg New Grad Coding Questions: 121 Questions (Part 2 of 2)