-
Notifications
You must be signed in to change notification settings - Fork 0
Unique Paths
andyaganrun edited this page Jul 9, 2017
·
1 revision
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there?
class Solution(object):
def uniquePaths(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
s=m+n-2
k=n-1
sum=1
for i in range(1,k+1):
sum=sum*(s-k+i)/i
return sum