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.
publicstaticintsolve(intn,intm){int[][]dpMatrix=newint[n+1][m+1];for(inti=0;i<=n;i++){dpMatrix[i][0]=0;}for(inti=0;i<=m;i++){dpMatrix[0][i]=1;}// Fill the DP tablefor(inti=1;i<=n;i++){for(intj=1;j<=m;j++){dpMatrix[i][j]=(dpMatrix[i-1][j]+dpMatrix[i][j-1])%MOD;}}returndpMatrix[n][m];}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Sherlock and Permutations
You are viewing a single comment's thread. Return to all comments →
java solution using dynamic programming