forked from rpj911/LeetCode_algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindLargeCommonLine.java
More file actions
70 lines (56 loc) · 1.68 KB
/
FindLargeCommonLine.java
File metadata and controls
70 lines (56 loc) · 1.68 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package Algorithms.algorithm.dp;
import java.util.ArrayList;
public class FindLargeCommonLine {
public static void main(String[] str) {
int[][] input = {
{0, 1},
{1, 0}
};
System.out.println(find(input));
}
public static class DpType {
ArrayList<Boolean> set0;
ArrayList<Boolean> set1;
int max0;
int max1;
public DpType(int max0, int max1) {
super();
this.set0 = new ArrayList<Boolean>();
this.set1 = new ArrayList<Boolean>();
this.max0 = max0;
this.max1 = max1;
}
}
public static int find(int[][] input) {
if (input == null || input.length == 0 || input[0].length == 0) {
return 0;
}
int rows = input.length;
int cols = input[0].length;
// create a DP
int[] max1 = new int[cols];
int[] max0 = new int[cols];
// initate to be one, means the first line.
int maxLine1 = 1;
int maxLine0 = 1;
for (int i = 0; i < cols; i++) {
if (input[0][i] == 0) {
// no change.
max0[i] = 0;
// should reverse.
max1[i] = 1;
} else {
max0[i] = 1;
max1[i] = 0;
}
}
// Dp from the 2nd line to the last.
for (int i = 1; i < rows; i++) {
boolean is0 = true;
for (int j = 0; j < cols; j++) {
//if (input[])
}
}
return 0;
}
}