We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 45e02ee commit bc0cd6eCopy full SHA for bc0cd6e
src/com/blankj/medium/_0062/Solution.java
@@ -0,0 +1,30 @@
1
+package com.blankj.medium._062;
2
+
3
+public class Solution {
4
5
+ public static void main(String[] args) {
6
+ Solution s = new Solution();
7
+ System.out.println(s.uniquePath(3, 2));
8
+ System.out.println(s.uniquePath(7, 3));
9
+ }
10
11
+ public int uniquePath(int m, int n) {
12
+ if (m <= 0 || n <= 0) {
13
+ return -1;
14
15
16
+ int[][] f = new int[m][n];
17
+ for (int i = 0; i < m; i++) {
18
+ f[i][0] = 1;
19
20
+ for (int j = 0; j < n; j++) {
21
+ f[0][j] = 1;
22
23
+ for (int i = 1; i < m; i++) {
24
+ for (int j = 1; j < n; j++) {
25
+ f[i][j] = f[i][j - 1] + f[i - 1][j];
26
27
28
+ return f[m - 1][n - 1];
29
30
+}
0 commit comments