Sort by

recency

|

147 Discussions

|

  • + 0 comments

    Sherlock’s approach often involves deducing the correct sequence of events from the numerous possible arrangements, much like finding the right permutation among many possible ones. This can be likened to solving a puzzle where all the elements need to fit together logically. Lion567 Login

  • + 0 comments

    java solution using dynamic programming

        public static int solve(int n, int m) {
            int[][] dpMatrix = new int[n+1][m+1];
            for(int i = 0; i<=n; i++){
                dpMatrix[i][0] = 0;
            }
           for(int i = 0; i<=m; i++){
                dpMatrix[0][i] = 1;
            }
        // Fill the DP table
            for (int i = 1; i <= n; i++) {
                for (int j = 1; j <= m; j++) {
                    dpMatrix[i][j] = (dpMatrix[i - 1][j] + dpMatrix[i][j - 1]) % MOD;
                }
            }
            return dpMatrix[n][m];
        }
    
  • + 0 comments

    solved as a comb def solve(n, m): return (math.factorial(n+m-1)//(math.factorial(m-1)*math.factorial(n))) % (10**9+7)

  • + 0 comments

    Sherlock Holmes' deductive prowess navigates the intricate permutations of mystery with unparalleled brilliance. Lotus365 com

  • + 1 comment

    Solution without math namespace, Python3:

    def solve(n, m):
        result = 1
        a = min(m-1, n)
        b = max(m-1, n)
        for i in range(1, b + 1):
            result *= (a + i)
            
        for j in range(1, b + 1):
            result //= j
            
        return result % (10**9 + 7)