-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinDeletionSize.java
More file actions
28 lines (24 loc) · 829 Bytes
/
Copy pathMinDeletionSize.java
File metadata and controls
28 lines (24 loc) · 829 Bytes
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
package LeetcodePractice;
public class MinDeletionSize {
public static int minDeletionSize(String[] strs) {
int n = strs.length, m = strs[0].length();
int count = 0;
for (int col = 0; col < m; col++) {
for (int row = 1; row < n; row++) {
if (strs[row].charAt(col) < strs[row - 1].charAt(col)) {
count++;
break;
}
}
}
return count;
}
public static void main(String[] args) {
String[] strs1 = {"cba","daf","ghi"};
String[] strs2 = {"a","b"};
String[] strs3 = {"zyx","wvu","tsr"};
System.out.println(minDeletionSize(strs1));
System.out.println(minDeletionSize(strs2));
System.out.println(minDeletionSize(strs3));
}
}