Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李楚霏
/
leetCode_Solution_Record
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
60122345
authored
4 years ago
by
李楚霏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
week6 唯一路径
parent
97bb1e2a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
+26
-0
70works/week6/unique_paths.cpp
+26
-0
No files found.
70works/week6/unique_paths.cpp
0 → 100644
View file @
60122345
class
Solution
{
public
:
int
uniquePaths
(
int
m
,
int
n
)
{
int
**
dp
=
new
int
*
[
m
+
1
];
for
(
int
i
=
0
;
i
<=
m
;
i
++
)
{
dp
[
i
]
=
new
int
[
n
+
1
];
}
for
(
int
i
=
1
;
i
<=
m
;
i
++
)
{
for
(
int
j
=
1
;
j
<=
n
;
j
++
)
{
if
(
i
==
1
||
j
==
1
)
{
dp
[
i
][
j
]
=
1
;
}
else
{
dp
[
i
][
j
]
=
dp
[
i
-
1
][
j
]
+
dp
[
i
][
j
-
1
];
}
}
}
int
res
=
dp
[
m
][
n
];
for
(
int
i
=
1
;
i
<=
m
;
i
++
)
{
delete
[]
dp
[
i
];
}
delete
[]
dp
;
return
res
;
}
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment