What is the best way to generate all unique combinations in JavaScript from N objects with R samples. For example:
n = [100,200,300,400]
r = 3
Expected result
[100,200,300]
[100,200,400]
[200,300,400]
[100,300,400]
I am able to achieve above using recursive solution. But it is slow for large datasets (e.g. N=25, R=10
). Is there any faster way to achieve this?