Leetcode Daily Problem - 3 Jan 2023
Leetcode Daily Challenge - Delete Columns to Make Sorted - 3 January 2023
Problem Name - Delete Columns to Make Sorted
Problem Link - https://leetcode.com/problems/delete-columns-to-make-sorted/description/
/**
* @param {string[]} strs
* @return {number}
*/
var minDeletionSize = function(strs) {
const rows = strs.length;
const cols = strs[0].length;
let ans=0;
// traversing column wise and counting the columns to be deleted
for(let j=0;j<cols;j++){
for(let i=1;i<rows;i++){
if(strs[i][j]<strs[i-1][j]){
ans++;
break;
}
}
}
return ans;
};