counting combinations and permutations efficiently

后端 未结 13 1951
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 12:38

I have some code to count permutations and combinations, and I\'m trying to make it work better for large numbers.

I\'ve found a better algorithm for permutations th

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 13:00

    For N choose K you could use Pascals triangle. Basically you would need to keep array of size N around to compute all the N choose K values. Only additions would be required.

提交回复
热议问题