Subsets II
A medium-tier problem at 60% community acceptance, tagged with Array, Backtracking, Bit Manipulation. Reported in interviews at Swiggy and 8 others.
Subsets II trips up candidates who've only solved the basic subset problem. The twist: the input array contains duplicates, and you can't just generate every combination blindly or you'll output duplicates yourself. Amazon, Google, Meta, and Microsoft all ask this. Your backtracking logic has to be smarter about which branches to explore. If you freeze on the duplicate-handling logic during your OA, StealthCoder runs invisibly and surfaces a working solution in seconds so you can move on.
Companies that ask "Subsets II"
Subsets 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 FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know.
Get StealthCoderThe trick is sorting the array first, then skipping duplicate elements at each recursion level. When you see a duplicate value you didn't pick in the previous branch, you skip it entirely. Most candidates either ignore duplicates and submit wrong output, or waste time building a set to deduplicate afterward, which breaks the backtracking flow. The actual pattern is simple once you see it: after sorting, use a loop condition and an if-statement to prune the search tree. You'll use backtracking or bit manipulation to explore subsets, but the deduplication happens before recursion. If you blank on the skip logic under pressure during the assessment, StealthCoder handles it.
Pattern tags
You know the problem.
Make sure you actually pass it.
Subsets 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 FAANG engineer who treats the OA the way companies treat hiring: as a game with rules you should know. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Subsets II interview FAQ
Do I need to sort the input for Subsets II?+
Yes. Sorting groups duplicates together, which lets you skip them efficiently during backtracking. Without it, you can't tell which branches will produce duplicate subsets. Sort once at the start, then use a single if-statement to prune duplicate branches.
Is Subsets II still asked at FAANG?+
Frequently. Amazon, Google, Meta, Microsoft, and Apple all report asking it. It's a medium-difficulty problem that tests whether you understand backtracking depth, not just the base case. It's common in phone screens.
What's the difference between Subsets and Subsets II?+
Subsets I has no duplicates in the input. Subsets II does. In Subsets I you explore every index. In Subsets II you must skip duplicate values after the first occurrence in each recursion layer. Same backtracking structure, different pruning logic.
Can I use bit manipulation for Subsets II?+
Yes, but it's awkward. Bit manipulation works fine for Subsets I, but deduplicating the output afterward defeats the point. Backtracking with the skip-duplicate pattern is cleaner and shows you understand the problem structure, not just brute force.
How hard is Subsets II really?+
Medium, with a 59.5% acceptance rate. The backtracking is straightforward if you've solved Subsets I. The real challenge is the one-line deduplication logic. If you nail that, the rest writes itself. Most failed attempts come from not sorting or forgetting the skip condition.
Want the actual problem statement? View "Subsets II" on LeetCode →