Snippets Collections
    int uniquePaths(int m, int n) {
        int N = m + n - 2, r = min(m, n)-1;
        long long p = 1;
        for(int i = 1 ; i <= r; i++){
            p = (p *(N - i + 1))/i;
        }
        return p;
    }
star

Tue May 30 2023 14:27:01 GMT+0000 (Coordinated Universal Time) https://leetcode.com/problems/unique-paths/

#c++ #unique_paths #combinatorics

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension