public int minDeletionSize(String[] strs) {
int m = strs.length;
int n = strs[0].length();
int[] dp = new int[n];
int ans = 0;
for (int i = 0; i < n; i++) {
dp[i] = 1;
for (int j = 0; j < i; j++) {
boolean isValid = true;
for (int k = 0; k < m; k++) {
if (strs[k].charAt(i) < strs[k].charAt(j)) {
isValid = false;
}
}
if (isValid) {
dp[i] = Math.max(dp[j] + 1, dp[i]);
}
ans = Math.max(dp[i], ans);
}
}
return n - ans;
}
标签:960,lc,int,isValid,++,strs,ans,dp
From: https://blog.51cto.com/u_14066730/11895545