public class Solution
{
public int MinDeletionSize(string[] A)
{
var result = ;
for (int j = ; j < A[].Length; j++)
{
for (int i = ; i < A.Length; i++)
{
if (A[i - ][j] > A[i][j])
{
result++;
break;
}
}
}
return result;
}
}
补充一版python3的实现代码:
class Solution:
def minDeletionSize(self, A):
count = 0
len1 = len(A)
len2 = len(A[0])
for j in range(len2):
a = ""
b = ""
for i in range(len1):
if(a == ""):
a = A[i][j]
else:
b = A[i][j]
if(a > b):
count += 1
break
a = b
return count