Source of the topic
https://leetcode.com/problems/unique-paths/
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 is there?
Test instructions Analysis
INPUT:M, N
Output:the Number of Unique path
Conditions: Output all possible paths
Topic ideas
A look at the whole arrangement, notice (m=3,n=7), that is to go down 2 steps to the right 6 steps, then the full arrangement can get the path is f (2+6)/(f (2) *f (6)), F is the factorial function
AC Code (PYTHON)
1 __author__='YE'2 3 classsolution (object):4 defuniquepaths (self, M, N):5 """6 : Type M:int7 : Type N:int8 : Rtype:int9 """Ten defFAC (n): OneF = 1 A forIinchRange (1, n + 1): -F *=I - returnF the -M-= 1 -N-= 1 - ifm = = 0orn = =0: + return1 - returnFAC (m + N)/(FAC (M) *FAC (n)) + A Print(Solution (). Uniquepaths (3, 7))
[Leetcode] (python): 062 Unique Path