062. Unique Paths
Question 62
Answer
v1. Permutations (98.4%)
class Solution(object):
def uniquePaths(self, m, n):
# there's only way when n==1
if n < 2:
return 1
# minus one for the start block
top = m + n -2
down = n -1
# permutations
for i in range(1,(n-1)):
top *= (m+n-2-i)
down *= (n-1-i)
return top/downLast updated