02/12/2022
πππ Tips- #24
Make cartesian products of two or more arrays recursively.
π° A cartesian product of two arrays is a permutation of all possible arrays of two elements whose first element belongs to the first array and the second element belongs to the second array.
π° For two arrays it's easy to generate the cartesian products but for more than two arrays it's a little complex.
The concept is easy. First, make the cartesian products of the first two arrays, keep the product in a new array and then repeat the process for the next arrays with the product array.
π° From this snippet you can learn:
β How to combine two or more arrays to generate cartesian products.
π¬ So, what do you think? Can you implement this using a recursive function? If you then don't forget to share a snippet.
π° Playground - https://lnkd.in/gkuYvxrY
π° Follow me on Twitter - https://twitter.com/ahamed_sajeeb