Simple Java Solution using Math Combination


  • 0
    D
    public class Solution {
        public int uniquePaths(int m, int n){
            int S=m+n-2, M=m-1;double sum=1;
            for(int i=1;i<=M;i++){
                sum=sum*(S-M+i)/i;
            }
            return (int)sum;
        }
    }

Log in to reply
 

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