Skip to content

Commit 16f1978

Browse files
authored
Create delete-columns-to-make-sorted-iii.py
1 parent 85f2b2c commit 16f1978

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Time: O(n * l^2)
2+
# Space: O(l)
3+
4+
class Solution(object):
5+
def minDeletionSize(self, A):
6+
"""
7+
:type A: List[str]
8+
:rtype: int
9+
"""
10+
dp = [1] * len(A[0])
11+
for j in xrange(1, len(A[0])):
12+
for i in xrange(j):
13+
if all(A[k][i] <= A[k][j] for k in xrange(len(A))):
14+
dp[j] = max(dp[j], dp[i]+1)
15+
return len(A[0]) - max(dp)

0 commit comments

Comments
 (0)