Problem 44241. NCHOOSEK - Time Optimization
Input
- V —— Set of all choices, a vector of N, 1 < N < 100
- K —— Number of selected choices, a scalar, 0 <= K <= N
Output
- C —— All combinations of V, equivalent to nchoosek(V, K)
Scoring
Time consumed
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
LY Cao
on 28 Jun 2017
nchoosekFast(V,K) should have the same behavior as nchoosek(V,K) for a vector V.
you can valid:
celldisp(nchoosek({[1 2],[5 6 7],3}, 2)),
nchoosek([3 1 2 2], 1).
li haitao
on 19 Nov 2018
Always return "While evaluating the solution, the server encountered an error caused by temporary unavailability of MATLAB Service. Wait a few minutes for the MATLAB Service to return, and then rescore."
Rafael S.T. Vieira
on 18 Jul 2020
Maybe you should forbid the use of nchoosek? Or is the MATLAB nchoosek faster currently? It passes the last test case without changes. Moreover, nchoosek runs within 1.30 s currently for the test case at an i5-3230M CPU, 2.60GHz. That's already pretty fast.
Solution Comments
Show commentsProblem Recent Solvers83
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!