62. Unique Pathshttps://leetcode.com/problems/unique-paths/description/题目难度:Medium
做题情况:顺滑
解题思路:
1. Initializatioin of the DP Table: start by creating a 2D list 'DP' of dimesions 'm' by 'n' where each cell is initially set to zero.
2. Setting Base Cases: The first row and the first column are filled with 1
s because there's only one way to get to any cell in the first row or the first column—by moving either right (for the first row) or down (for the first column).
3. Filling the DP Table: For each cell in the grid that is not on the top row or the first column, the number of ways to reach that cell is the sum of the number of ways to reach the cell directly above it and the cell directly to the left of it.
时间复杂度:O(m * n)
空间复杂度:O(m * n)
63. Unique Paths IIhttps://leetcode.com/problems/unique-paths-ii/description/题目难度:Medium
做题情况:顺滑
解题思路:和上一题非常像,但是在设置初始值时,如果在最上面一行和最左边一列遇到了障碍,则要把障碍的那一格和后面的格子初始值都设为0
时间复杂度:O(m * n)
空间复杂度:O(m * n)