problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::unique_paths::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static int uniquePaths (int m, int n)
 

详细描述

在文件 leetcode.h2450 行定义.

成员函数说明

◆ uniquePaths()

int leetcode::unique_paths::Solution::uniquePaths ( int  m,
int  n 
)
static

在文件 leetcode.cpp6566 行定义.

6566 {
6567 vector dp(m, vector(n, 0));
6568 dp[m - 1][n - 1] = 1;
6569 for(int i = m - 1; i >= 0; i--) {
6570 for(int j = n - 1; j >= 0; j--) {
6571 if(i + 1 < m) {
6572 dp[i][j] += dp[i + 1][j];
6573 }
6574 if(j + 1 < n) {
6575 dp[i][j] += dp[i][j + 1];
6576 }
6577 }
6578 }
6579 return dp[0][0];
6580 }

被这些函数引用 leetcode::unique_paths::TEST().


该类的文档由以下文件生成: