Medium · Backtracking
Cartesian Product of Multiple Arrays
Given lists, an array of string arrays, return every distinct tuple that takes exactly one element from each list, in list order. Return the tuples in any order; a tuple that can be built more than once, because a list repeats an element, appears only once.
Examples
Example 1
[[1,2],[3,4],[5]]Output: 4 tuples
Example 2
[[a,b],[x,y]]Output: 4 tuples
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.