Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
There is a problem with the function you propose: For example if we call combinationGroup([0,1,2,3],2,2) we will have: [ [0,1],[2,3] ] as only output; but result should have also [ [0,2],[1,3] ] and [ [0,3],[1,2] ]. Maybe look at another question relative to the number of result I should have with this algorithm on MathOverflow - Concerning your combinations method, it works well, but look much more complicated than mine genCombinations1
Ok, so I will reset the message as I posted originally; I thought it was too complex and could be reduced to the needs of this question. Please check :) ! Here you will see at the end of the snippet code an example of execution.
Ok so let's check my actual code so ! I don't really now what you want to see inside it but ok.. My problem is still to rewrite the genCombinations2 function to not being recursive anymore (like genCombinations1 that is not recursive)
Wow !! Very interesting ! It was somethng like this distinct operator I wanted to find. 1: Yes there is an index on vid, so this will work; 2: Took 4s for me (just one try), perfect; Thank you @felix