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.
Just thought I should mention, if you did the Matrix Traversal question, this is basically the same thing.
Matrix traversal boiled down to the number of combinations of "move-up" actions and "move-right" actions. Now we want the total number of combinations of 0's and 1's in the string resulting from ignoring the first element.
First item is fixed to 1, as we are uninterested in the other case, so the answer is choose(m-1,m+n-1). In the Matrix question the answer was choose(m-1,m+n-2), so you need only make a small change to your old code.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Permutations
You are viewing a single comment's thread. Return to all comments →
Just thought I should mention, if you did the Matrix Traversal question, this is basically the same thing. Matrix traversal boiled down to the number of combinations of "move-up" actions and "move-right" actions. Now we want the total number of combinations of 0's and 1's in the string resulting from ignoring the first element. First item is fixed to 1, as we are uninterested in the other case, so the answer is choose(m-1,m+n-1). In the Matrix question the answer was choose(m-1,m+n-2), so you need only make a small change to your old code.