FastPrepExpand Attribute Combinations
Problems/Expand Attribute Combinations

Expand Attribute Combinations

Pinterest logoPinterest● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Pinterest phone screen. The report names the task of building all combinations from lists of values, which is a Cartesian product. It does not say how to write the output, in what order to list the combinations, or what to do with empty input. Here, the result is ordered rows that line up with the input keys.

A product configuration has distinct attribute names in keys. For each index i, values[i] lists the allowed values for keys[i].

Return every assignment in the Cartesian product. Represent one assignment as a row whose value at index i belongs to keys[i]. Preserve the input key order within each row, and enumerate rows by choosing values from left to right in their given order.

If there are no keys, return one empty assignment. If any attribute has no allowed values, return no assignments.

Function

expandAttributeCombinations(keys: String[], values: String[][]) → String[][]

Examples

Example 1

keys = ["color","size"]values = [["red","blue"],["S","M"]]return = [["red","S"],["red","M"],["blue","S"],["blue","M"]]

Each color is paired with each size. The first attribute changes more slowly because combinations are enumerated from left to right.

Example 2

keys = ["region","tier","mode"]values = [["us"],["free","pro"],["light","dark"]]return = [["us","free","light"],["us","free","dark"],["us","pro","light"],["us","pro","dark"]]

The single region appears in every row, while the two later attributes generate four combinations.

Example 3

keys = []values = []return = [[]]

The Cartesian product of zero attribute sets contains one empty assignment.

Constraints

  • 0 <= keys.length == values.length <= 12.
  • Every key is non-empty, and keys are distinct.
  • Each value is a non-empty string; values within one attribute are distinct.
  • The total number of returned assignments is at most 100000.

More Pinterest Phone Screen questions

  • Shortest Pin Path Through TopicsPHONE SCREEN · Seen Nov 2026
  • Top K Pins with Insert and QueryPHONE SCREEN · Seen Nov 2026
  • Pins Violation Log QueriesPHONE SCREEN · Seen Nov 2026
  • Sparse Matrix Addition and MultiplicationPHONE SCREEN · Seen Nov 2026
  • Minimum Bus Routes to a DestinationPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Delete and Compact a Forest SubtreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Optimal Account BalancingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Aggregate Matching IPv4 Addresses Across ResponsesPHONE SCREEN · Seen Oct 2026
  • Escape Room LeaderboardPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Shortest Way to Form a Target StringPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Winning Draws for a Mahjong HandZip · PHONE SCREENZip interview questions
  • Alternating Parity PermutationsGoldman Sachs · OAGoldman Sachs interview questions
  • Generate Circular Student ArrangementsAmazon · ONSITE INTERVIEW
  • Inventory Outfit CombinationsRoblox · ONSITE INTERVIEWRoblox interview questions
  • Count Legal Outfit CombinationsDuolingo · OADuolingo interview questions
  • Partition into Equal-Sum GroupsPalo Alto Networks · ONSITE INTERVIEWPalo Alto Networks interview questions
  • Largest Number Below N from Reusable DigitsByteDance · PHONE SCREENByteDance interview questions
  • Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
  • Find Valid SET Card TriplesSnowflake · OA · PHONE SCREENSnowflake interview questions
  • SubsetsTemu · PHONE SCREENTemu interview questions

Pinterest interview experiences

  • Pinterest Experienced MLE Phone Screen: 1 Experience
All Pinterest interview questionsSee Pinterest hiring insights
Saved
class Solution {
    public String[][] expandAttributeCombinations(String[] keys, String[][] values) {
      // write your code here
    }
}
Checking account…