Delete Columns to Make Sorted LeetCode solution in Java

1
class Solution {
2
public int minDeletionSize(String[] strs) {
3
int count = 0;
4
for (int i = 0;
5
i < strs[0].length();
6
i++) { // strs[0].length() is used to find the length of the column
7
for (int j = 0; j < strs.length - 1; j++) {
8
if ((int) strs[j].charAt(i) <= (int) strs[j + 1].charAt(i)) {
9
continue;
10
} else {
11
count++;
12
break;
13
}
14
}
15
}
16
return count;
17
}
18
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0