955. Delete Columns to Make Sorted II
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nGood problem\nDifficult problem\n\n# Complexity\n- Time complexity:\n Add
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nGood problem\nDifficult problem\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n\n---\n\n```\nvar minDeletionSize = function (words) {\n    const m = words.length;\n    const n = words[0].length;\n    const goodColOnLeft = Array(m).fill("");\n    let numberOfColumsToDelete = 0;\n    OUTER: for (let C = 0; C < n; C++) {\n        for (let R = 1; R < m; R++) {\n            if (goodColOnLeft[R - 1] === goodColOnLeft[R]) {\n                const prevRowCh = words[R - 1][C];\n                const currRowCh = words[R][C];\n                if (prevRowCh > currRowCh) {\n                    numberOfColumsToDelete++;\n                    continue OUTER;\n                }\n            }\n        }\n        for (let R = 0; R < m; R++) {\n            goodColOnLeft[R] += words[R][C];\n        }\n    }\n    return numberOfColumsToDelete;\n    // return n - goodColOnLeft[0].length;\n};\n```\n\n---\n
['JavaScript']