The problem you learned in high school?


  • 4
    N

    Come on leetcode...

    int uniquePaths(int m, int n) {
    	// (m+n-2) Combination (n-1)
    	int right = min(m, n) - 1, left = m + n - 2;
    	int iter = right;
    	double ret = 1;
    
    	for (int i = 1; i <= iter; i++)
    	{
    		ret *= left--;
    		ret /= right--;
    	}
    	return round(ret);
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.