MEDIUMasked at 9 companies

Permutations II

A medium-tier problem at 62% community acceptance, tagged with Array, Backtracking, Sorting. Reported in interviews at LinkedIn and 8 others.

Founder's read

Permutations II hits your assessment and you blank on how to skip duplicates without generating garbage. You're asked to return all unique permutations of an array containing duplicates. LinkedIn, TikTok, Microsoft, and Meta all ask this. The acceptance rate sits around 61.6%, meaning most people either timeout on naive backtracking or bust trying to deduplicate after the fact. The trick isn't complex, but you have to see it live. If you freeze, StealthCoder surfaces the working solution invisible to the proctor.

Companies asking
9
Difficulty
MEDIUM
Acceptance
62%

Companies that ask "Permutations II"

If this hits your live OA

Permutations II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The pattern: sort the array first, then use backtracking with a visited array to track used indices per recursion level. When you hit a duplicate value at the same recursion depth, skip it. The naive approach generates all permutations then deduplicates, which TLEs on larger inputs. The correct move is preventing duplicate branches during generation, not after. Most candidates either forget to sort, or they try to use a set to skip duplicates without tracking recursion depth, which breaks the permutation structure. Array, Backtracking, and Sorting are the three topics. During a live OA, if the logic slips, StealthCoder runs invisibly and gives you the implementation in seconds so you can paste and move on.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Permutations II recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Permutations II interview FAQ

Is sorting the array really necessary for Permutations II?+

Yes. Sorting lets you identify duplicate values and skip them intelligently during backtracking. Without it, you can't tell which duplicates are adjacent, so you either generate all permutations then filter (TLE) or use a flawed set-based skip that breaks the permutation structure.

Why does using a set of seen values at each recursion level fail?+

A set prevents the same value from appearing twice in a single permutation, but it doesn't prevent duplicate branches across different permutation paths. The visited array tracks indices per recursion depth, not global uniqueness. That distinction is the core trick.

Do top companies like Amazon and Apple still ask this?+

Yes. This problem appears in reports from nine major companies including Amazon, Apple, Meta, and Microsoft. It tests backtracking maturity and shows whether you understand the difference between global deduplication and branch-level deduplication.

What's the time complexity and does it matter for passing?+

O(n! * n) worst case, where n! is the number of unique permutations. The constant factors matter because naive approaches with post-generation filtering often hit TLE. The early-skip approach using sorted order and visited tracking is the expected solution.

How does this relate to the standard Permutations problem?+

Standard permutations assumes all elements are unique, so backtracking is straightforward. Permutations II adds the duplicates constraint, forcing you to add sorting and recursion-depth-aware duplicate skipping. It's the same backtracking skeleton with one critical guard.

Want the actual problem statement? View "Permutations II" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.