@@ -0,0 +1,1880 @@
+%22%22%22 Unique Paths%0A%0AA robot is located at the top-left corner of a m x n grid%0A(marked 'Start' in the diagram below).%0A%0AThe robot can only move either down or right at any point in time.%0AThe robot is trying to reach the bottom-right corner of the grid%0A(marked 'Finish' in the diagram below).%0A%0A%0A+-----------+-----+-----+-----+-----+-----+%0A%7Cstart%7C     %7C     %7C     %7C     %7C     %7C     %7C%0A%7C     %7C     %7C     %7C     %7C     %7C     %7C     %7C%0A+-----------------------------------------+%0A%7C     %7C     %7C     %7C     %7C     %7C     %7C     %7C%0A%7C     %7C     %7C     %7C     %7C     %7C     %7C     %7C%0A+-----------------------------------------+%0A%7C     %7C     %7C     %7C     %7C     %7C     %7Cfinish%0A%7C     %7C     %7C     %7C     %7C     %7C     %7C     %7C%0A+-----+-----+-----+-----+-----+-----+-----+%0A%0A!%5Bleetcode picture%5D(https://assets.leetcode.com/uploads/2018/10/22/robot_maze.png)%0A%0AHow many possible unique paths are there ?%0A%0AExample 1:%0A%0A    Input: m = 3, n = 2%0A    Output: 3%0A    Explation:%0A%0A    From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:%0A    1. Right -%3E Right -%3E Down%0A    2. Right -%3E Down -%3E Right%0A    3. Down -%3E Right -%3E Right%0A%0A%0AExample 2:%0A%0A    Input: m = 7, n = 3%0A    Output: 28%0A%0A%0AConstraints:%0A%0A* 1 %3C= m, n %3C= 100%0A* It's guaranteed that the answer will be less than or equal to 2 * 10 %5E 9.%0A%0A%22%22%22%0A%0A%0Aclass Solution:%0A%0A    def uniquePaths(self, m: int, n: int) -%3E int:%0A        %22%22%22DP solution%0A        %E7%BB%B4%E6%8A%A4%E4%B8%80%E4%B8%AA%E4%BA%8C%E7%BB%B4%E6%95%B0%E7%BB%84 dp%EF%BC%8C%E5%85%B6%E4%B8%AD dp%5Bi%5D%5Bj%5D %E8%A1%A8%E7%A4%BA%E5%88%B0 i,j %E6%89%80%E5%9C%A8%E4%BD%8D%E7%BD%AE%E4%B8%8D%E5%90%8C%E7%9A%84%E8%B5%B0%E6%B3%95%E7%9A%84%E4%B8%AA%E6%95%B0%0A        %E5%8F%AF%E4%BB%A5%E8%8E%B7%E5%BE%97%E7%8A%B6%E6%80%81%E8%BD%AC%E7%A7%BB%E6%96%B9%E7%A8%8B dp%5Bi%5D%5Bj%5D = dp%5Bi-1%5D + dp%5Bi%5D%5Bj-1%5D%0A        %22%22%22%0A        # %E4%BD%BF%E7%94%A8%E4%B8%80%E7%BB%B4%E6%95%B0%E7%BB%84%E5%AE%9E%E7%8E%B0%0A        dp = %5B1%5D * n%0A        for i in range(1, m):%0A            for j in range(1, n):%0A                dp%5Bj%5D += dp%5Bj - 1%5D%0A        return dp%5Bn - 1%5D%0A%0A%0Aif __name__ == '__main__':%0A    cases = %5B%0A        ((3, 2), 3),%0A        ((7, 3), 28),%0A    %5D  # yapf: disable%0A%0A    for case in cases:%0A        for S in %5BSolution%5D:%0A            assert S().uniquePaths(case%5B0%5D%5B0%5D, case%5B0%5D%5B1%5D) == case%5B1%5D%0A

Add leetcode 062 solution