62.不同路径
思路:
因为只能向左,和向下,因此只能是前面的加上左边的,递推公式较为简单
代码:
1 int uniquePaths(int m, int n) { 2 if (m == 1 || n == 1) return 1; 3 4 vector<vector<int>> nums(m, vector<int>(n, 1)); 5 6 for (int i = 1; i < m; i++) 7 { 8 for (int j = 1; j < n; j++) 9 { 10 nums[i][j] = nums[i][j - 1] + nums[i - 1][j]; 11 } 12 } 13 14 return nums[m - 1][n - 1]; 15 }
标签:nums,int,路径,随想录,II,62,63 From: https://www.cnblogs.com/smartisn/p/17556151.html