Greedy O(m * m * n)
IntuitionUse greedy approach. Go from the leftmost to the right, since the leftmost column is the most important.Approach
Use an array prevs to store previously
# Intuition
Use greedy approach. Go from the leftmost to the right, since the leftmost column is the most important.
# Approach
1. Use an array prevs to store previously kept prefix.
2. Go from the leftmost column. For each character, we add the prefix stored in the corresponding index in prevs, and compare. If there is an inverse, we must delete the column, and increment the result.
3. If it's already sorted, we update prevs, adding the current column's character for each index.
# Complexity
- Time complexity:
O(m * m * n)
- Space complexity:
O(m * n)
# Code
```javascript []
/**
 * @param {string[]} strs
 * @return {number}
 */
var minDeletionSize = function(strs) {
    const len = strs.length, size = strs[0].length
    const prevs = new Array(len).fill('')


    let result = 0
    forEachJ:
    for (let j = 0; j < size; j++) {
        for (let i = 1; i < len; i++) {
            const strA = prevs[i - 1] + strs[i - 1][j]
            const strB = prevs[i] + strs[i][j]
            if (strA > strB) {
                result++
                continue forEachJ
            }
        }

        for (let i = 0; i < len; i++)
            prevs[i] += strs[i][j]
    }


    return result
};
```
['JavaScript']