-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinDeletionSize944.java
More file actions
43 lines (38 loc) · 1.11 KB
/
MinDeletionSize944.java
File metadata and controls
43 lines (38 loc) · 1.11 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
public class MinDeletionSize944 {
public static void main(String[] args) {
// System.out.println(minDeletionSize(new String[] {"a","b"}));
System.out.println(minDeletionSize(new String[] {"xflbebb","fzqetdc","xktuxef","gfvxchu","goyyhiv"}));
//System.out.println(minDeletionSize(new String[] {"cba","daf","ghi"}));
// System.out.println(minDeletionSize(new String[] {"zyx","wvu","tsr"}));
}
public static int minDeletionSize(String[] A) {
int ret = 0;
if(A.length == 1) {
return 0;
}
char[] line = A[0].toCharArray();
for(char c : line) {
System.out.println(c);
}
System.out.println();
char[] now;
for(String str : A) {
now = str.toCharArray();
for(int i = 0; i < line.length; i++) {
if('-' == line[i]) {
continue;
}
if(now[i] >= line[i]) {
line[i] = now[i];
}
else {
line[i] = '-';
ret++;
}
System.out.println("line[" + i + "] is " + line[i] + " " + now[i] + " <-- " + (now[i] >= line[i]));
}
System.out.println();
}
return ret;
}
}