FastPrepPermutations II
Problems/Permutations II

Permutations II

LinkedIn logoLinkedIn● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report identifies this task and its central operation. This practice version states the deterministic interface, boundary behavior, and ordering rules needed for consistent execution while preserving the reported capability.

Given a lowercase string s, return every distinct permutation of its characters exactly once.

Return the permutations in ascending lexicographic order. Equal characters from different input positions must not create duplicate strings.

Function

uniquePermutations(s: String) → String[]

Examples

Example 1

s = "aab"return = ["aab","aba","baa"]

There are three distinct arrangements after duplicate swaps of the two a characters are removed.

Example 2

s = "xxyy"return = ["xxyy","xyxy","xyyx","yxxy","yxyx","yyxx"]

The four positions have six unique arrangements because each character appears twice.

Example 3

s = "z"return = ["z"]

A one-character string has one permutation.

Constraints

  • 1 <= s.length <= 8.
  • s contains only lowercase English letters.

More LinkedIn problems

  • Explore an Unknown Grid and Find a PathONSITE INTERVIEW · Seen Nov 2026
  • Fire Station Response BillONSITE INTERVIEW · Seen Nov 2026
  • Sum an Arbitrary-Dimensional ArrayPHONE SCREEN · Seen Oct 2026
All LinkedIn interview questionsSee LinkedIn hiring insights
Saved
class Solution {
    public String[] uniquePermutations(String s) {
      // write your code here
    }
}
Checking account…