FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode/code/lc62.java at master · mJackie/leetcode · GitHub
mJackie
/
leetcode
Public
Notifications
You must be signed in to change notification settings
Fork
135
Star
405
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode
/
code
/
lc62.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (29 loc) · 885 Bytes
Breadcrumbs
leetcode
/
code
/
lc62.java
Copy path
File metadata and controls
30 lines (29 loc) · 885 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package
code
;
/*
* 62. Unique Paths
* 题意:求从数组[0,0]走到[m,n]的不同路径数
* 难度:Medium
* 分类:Array, Dynamic Programming
* 思路:和lc63, lc64思路一样, arr存储的内容由路径数换成了和
*/
public
class
lc62
{
public
static
void
main
(
String
[]
args
) {
System
.
out
.
println
(
uniquePaths
(
7
,
3
));
}
public
static
int
uniquePaths
(
int
m
,
int
n
) {
int
[][]
arr
=
new
int
[
m
][
n
];
for
(
int
i
=
0
;
i
<
m
;
i
++) {
for
(
int
j
=
0
;
j
<
n
;
j
++) {
if
(
i
==
0
&&
j
==
0
)
arr
[
i
][
j
] =
1
;
else
if
(
i
==
0
)
arr
[
i
][
j
] =
arr
[
i
][
j
-
1
];
else
if
(
j
==
0
)
arr
[
i
][
j
] =
arr
[
i
-
1
][
j
];
else
arr
[
i
][
j
] =
arr
[
i
-
1
][
j
]+
arr
[
i
][
j
-
1
];
}
}
return
arr
[
m
-
1
][
n
-
1
];
}
}
Back
|
FazBrowse Home
|
New Git URL