Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ff29bf9

Browse files
author
fupengfei058
committed
02/10 COMMIT
1 parent dd47a7c commit ff29bf9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎Leetcode/62. Unique Paths.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*Unique Paths:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
2+
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).
3+
How many possible unique paths are there?*/
4+
class Solution {
5+
public:
6+
int uniquePaths(int m, int n) {
7+
//dp Fn=Fn-1+Fn
8+
vector<int> vec(n, 1);
9+
for(int i=1; i<m; ++i){
10+
for(int j=1; j<n; ++j){
11+
vec[j]+=vec[j-1];
12+
}
13+
}
14+
return vec[n-1];
15+
}
16+
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /