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 edb4dd5

Browse files
committed
Add solution 62.
1 parent 4be7962 commit edb4dd5

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
3+
/**
4+
* @param Integer $m
5+
* @param Integer $n
6+
* @return Integer
7+
*/
8+
function uniquePaths($m, $n) {
9+
$dp=array_fill(0, $m, array_fill(0, $n, 0));
10+
11+
$dp[0] = array_fill(0, $n, 1);
12+
13+
for($r=0;$r<$m;$r++) $dp[$r][0]=1;
14+
15+
for($r=1;$r<$m;$r++){
16+
for($c=1;$c<$n;$c++){
17+
$dp[$r][$c]=$dp[$r-1][$c]+$dp[$r][$c-1];
18+
}
19+
}
20+
return $dp[$m-1][$n-1];
21+
}
22+
}

0 commit comments

Comments
(0)

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