Skip to content
Advertisement

Tag: cartesian-product

How to get Cartesian product from multiple lists?

Say I have several List<T>s, I will put them into another list or other collections, so I don’t know how many list<T> I have until I call List<List<T>>.size() Take below List<Integer> as an example: How can I get the result of list1*list2*list3*…listn as a Cartesian product? For example: should be: Answer You can use recursion to achieve it, your base

Advertisement