FastPrepAll Rearrangements of a String
Problems/All Rearrangements of a String

All Rearrangements of a String

Adobe logoAdobe● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: This problem returns every different rearrangement of a short string's letters, each once, in dictionary order. An Adobe Noida report for a Selenium test-automation role lists a string-permutation coding task, to be solved in Java, in its first round (a one-hour technical interview), after framework and Java questions; it gives no rule for repeated letters, output order, limits or examples.

Our choices: return the strings instead of printing them, each different string once, dictionary order, lowercase letters, 1 to 6 letters, any of five languages instead of Java only, and new examples.

The judged task matches the report at about 80%.

Given a string s, return every different string that can be made by rearranging all of its letters.

If s has repeated letters, list each resulting string only once. Return the strings sorted in dictionary order.

Function

allPermutations(s: String) → List<String>

Examples

Example 1

s = "dog"return = ["dgo","dog","gdo","god","odg","ogd"]

Three different letters give 3 x 2 x 1 = 6 orders. Sorted like dictionary words, dgo comes first and ogd last.

Example 2

s = "ebb"return = ["bbe","beb","ebb"]

Swapping the two bs gives the same string, so there are only 3 different orders, not 6: bbe, beb, ebb.

Example 3

s = "q"return = ["q"]

One letter has one order.

Constraints

  • 1 <= s.length <= 6
  • s contains only lowercase English letters; letters may repeat

More Adobe problems

  • Evaluate a Parenthesized Integer ExpressionPHONE SCREEN · Seen Oct 2026
  • All Elements of Two BSTs in OrderPHONE SCREEN · Seen Aug 2026
  • Rotate an Array In PlaceOA · PHONE SCREEN · Seen Aug 2026
All Adobe interview questionsSee Adobe hiring insights
Saved
public List<String> allPermutations(String s) {
    // Write your code here.
}
Checking account…