We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My approach was to bottom-up fill an array A[i][j]. Where each cell represents the total number of ways you can select i elements from j possibiliities. The answer to the problem would be represented by the cell A[k-1][n-1].
The solution seems right, nevertheless I get a "Timeout Error" for the testcases 3 & 5. Is there a much more efficient way to solve that problem?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Different Ways
You are viewing a single comment's thread. Return to all comments →
My approach was to bottom-up fill an array
A[i][j]
. Where each cell represents the total number of ways you can selecti
elements fromj
possibiliities. The answer to the problem would be represented by the cellA[k-1][n-1]
.The solution seems right, nevertheless I get a "Timeout Error" for the testcases 3 & 5. Is there a much more efficient way to solve that problem?