Inventory Outfit Combinations
Updated
Problem statement
A user’s inventory is described by two arrays, categories and itemIds. At each index, itemIds gives an item’s ID and categories gives its clothing category.
For this exercise, assume an outfit contains exactly one item from every category present in the inventory. Every combination of those choices is compatible, and no additional optional category or compatibility rule applies. Different item IDs are different choices.
Return all outfits. Within each outfit, list item IDs in increasing category order. Sort the outfit rows lexicographically by their item IDs: compare the first differing position numerically. The input arrays may be unsorted. An empty inventory returns an empty array of outfits.
Function
combineOutfits(categories: int[], itemIds: int[]) → int[][]Examples
Example 1
categories = [1,0,1,0]itemIds = [20,3,10,1]return = [[1,10],[1,20],[3,10],[3,20]]Category 0 offers 1 or 3, and category 1 offers 10 or 20. List all four ordered combinations.
Example 2
categories = [3,3]itemIds = [9,2]return = [[2],[9]]Only category 3 is present, so each of its items forms one outfit.
Example 3
categories = []itemIds = []return = []An empty inventory produces no outfit.
Constraints
0 <= itemIds.length <= 16andcategories.length = itemIds.length.0 <= categories[i] <= 3, and each category contains at most4items.- Item IDs are distinct integers in
0..10^9. - At most
256outfits can be returned.
More Roblox Onsite Interview questions
- Most Frequent Call Path From Function Trace LogsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Count and Score Distinct Hat AssignmentsONSITE INTERVIEW · Seen Sep 2026
- Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Most Frequent Call Path in Interleaved LogsONSITE INTERVIEW · Seen Aug 2026
- Grid Pathfinding with Obstacles (DFS)PHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026
- Maximize Distance to Closest Person — Return the SeatONSITE INTERVIEW · Seen Jun 2026
Similar questions at other companies
- Generate Circular Student ArrangementsAmazon · ONSITE INTERVIEW
- Partition into Equal-Sum GroupsPalo Alto Networks · ONSITE INTERVIEWPalo Alto Networks interview questions
- Expand Attribute CombinationsPinterest · PHONE SCREENPinterest interview questions
- Alternating Parity PermutationsGoldman Sachs · OAGoldman Sachs interview questions
- Winning Draws for a Mahjong HandZip · PHONE SCREENZip interview questions
- Count Legal Outfit CombinationsDuolingo · OADuolingo interview questions
- Generate All Permutations of a NumberFleetx · ONSITE INTERVIEW
- Unique Single-Use Sum CombinationsLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
- Generate Fixed-Size CombinationsMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- Bounded Combination Sum with Signed CandidatesConfluent · ONSITE INTERVIEWConfluent interview questions