- 2

write a java script function to get all possible subset with a fixed length ( for example 2 ) combination in an array. sample ar

write a java script function to get all possible subset with a fixed length ( for example 2 ) combination in an array. sample array :( 1 , 2 , 3) and subset length is 2 expected out put :((2,1), (3,1), (3,2), (3,2,1))

17th Dec 2016, 6:43 PM
Nashwan Aziz
Nashwan Aziz - avatar
1 Resposta
0
I don't fully understand the question: you don't specify if your subsets can have repeated elements if the original array has repeated elements as well, one your example's subsets' length is 3, etc. Anyway, you might want to check out this function: https://code.sololearn.com/WVDQyH7JRLIH/#js I hope it helps. PS: Please don't spam.
29th Mar 2017, 12:00 PM
Luca Garrera