Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e0bfc93

Browse files
committed
Solve 944. Delete Columns to Make Sorted
1 parent 46c5935 commit e0bfc93

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class Solution {
2+
3+
fun minDeletionSize(strs: Array<String>): Int {
4+
var columnsToDelete = 0
5+
val rows = strs.count()
6+
val columns = strs[0].length
7+
8+
for (i in 0..(columns - 1)) {
9+
var left = 0
10+
var right = 1
11+
12+
while (right < rows) {
13+
if (strs[left][i] > strs[right][i]) {
14+
columnsToDelete++
15+
break
16+
}
17+
18+
left++
19+
right++
20+
}
21+
}
22+
23+
return columnsToDelete
24+
}
25+
26+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /