leetcode 944 Delete Columns to Make Sorted
贪心算法:如果某一列not sorted,删除该列;时间O(A),空间O(1) C++代码:
class Solution { public: int minDeletionSize(vector<string>& A) { //删除每一列非升序子序列; int cnt=0; for(int j=0;j<A[0].size();j++){ for(int i=1;i<A.size();i++){ if(A[i][j]<A[i-1][j]){ cnt++;break; } } } return cnt; } };