FastPrepPermutations of Character Positions
Problems/Permutations of Character Positions

Permutations of Character Positions

PeopleStrong logoPeopleStrong● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two PeopleStrong reports from onsite interviews ask for recursive character permutations. The linked reference keeps repeated characters at different positions as separate items, and this version says that rule clearly. We chose the sorting, the result for empty input, and the limits. Our version is about 90% the same as the reported questions.

Given a string s, return all ways to arrange its character positions, sorted in ascending lexicographic order. Use recursion to generate the permutations.

For this exercise, treat characters at different input positions as separate choices, even when they are the same letter. Keep repeated output strings: AAA therefore produces six copies of AAA. An empty input has one permutation, the empty string.

Function

characterPermutations(s: String) → String[]

Examples

Example 1

s = "ABC"return = ["ABC","ACB","BAC","BCA","CAB","CBA"]

The three distinct positions have 3 factorial, or 6, orderings.

Example 2

s = "AAA"return = ["AAA","AAA","AAA","AAA","AAA","AAA"]

The six positional orderings happen to spell the same string; none is discarded.

Constraints

  • For this exercise, assume 0 <= s.length <= 7.
  • The string contains uppercase or lowercase English letters.
  • Use ordinary ASCII lexicographic order; uppercase letters sort before lowercase letters.
  • Return every positional permutation, including duplicate strings.

More PeopleStrong Onsite Interview questions

  • Add Two Binary StringsONSITE INTERVIEW · Seen Mar 2026
  • Four SumONSITE INTERVIEW · Seen Mar 2026
  • LRU Cache OperationsONSITE INTERVIEW · Seen Mar 2026
  • Sliding Window MaximumONSITE INTERVIEW · Seen Mar 2026
  • Find the Entry of a Linked List CycleONSITE INTERVIEW · Seen Sep 2025
  • Integer to English Words: Up to 20 DigitsONSITE INTERVIEW · Seen Sep 2025
  • Word Ladder II: All Shortest TransformationsONSITE INTERVIEW · Seen Sep 2025
  • Detect a Cycle in a Linked ListONSITE INTERVIEW · Seen May 2025
  • First Nonrepeating CharacterONSITE INTERVIEW · Seen May 2025
  • Longest Subarray with a Target SumONSITE INTERVIEW · Seen May 2025

Similar questions at other companies

  • Phone Keypad Letter CombinationsGoogle · ONSITE INTERVIEWGoogle interview questions
  • Permutations of Unique CharactersSalesforce · PHONE SCREENSalesforce interview questions
  • Generate Balanced ParenthesesInMobi · OAInMobi interview questions
  • 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
  • DFS Subsequences of a String (For MLE)Wayfair · OAWayfair interview questions
  • Count Complete Tic-Tac-Toe GamesDecagon · PHONE SCREEN · ONSITE INTERVIEWDecagon interview questions
  • Single-Pass S-Expression ParserBaseten · ONSITE INTERVIEWBaseten interview questions
  • Generate Fixed-Size CombinationsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions

Interview reports that mention this question

  • PeopleStrong SDE OA and Interview Questions: 12 Experiences
All PeopleStrong interview questionsSee PeopleStrong hiring insights
Saved
class Solution {
    public String[] characterPermutations(String s) {
        // Write your solution here.
    }
}
Checking account…