Well explained with examples
Intuition\nHow to compare 2 numbers\n135 <> 125\nwe compare first digit they are the same (1==1) it is not enoug to make a decision so we continue to a second d
# Intuition\nHow to compare 2 numbers\n135 <> 125\nwe compare first digit they are the same (1==1) it is not enoug to make a decision so we continue to a second digit,3>2 we\'ve found that 135 > 125, we stop immediatly there is no point to continue to a 3rd digit\n  \n\n# Approach\nBest to explain is using an example\n```\n["vdy","vei","zvc","zld"], expected answer is 2\n```\nI convert it to numbers\n\n```\n[ 21, 3, 24 ], [ 21, 4, 8 ], [ 25, 21, 2 ], [ 25, 11, 3 ]\n     i-1             i\n  21==21 so we continue to next character\n  3<4    we found that strs[i] is greater, nothing needs to be deleted\n\n```\n\n```\n[ 21, 3, 24 ], [ 21, 4, 8 ], [ 25, 21, 2 ], [ 25, 11, 3 ]\n                   i-1             i\n  21<25 everything is in order, strs[i] is greater, nothing needs to be deleted\n```\n\n```\n[ 21, 3, 24 ], [ 21, 4, 8 ], [ 25, 21, 2 ], [ 25, 11, 3 ]\n                                   i-1             i\n  25==25 continue to next character\n  21>11  We detected invalid order, column at index 1 needs to be deleted (marking it as deleted)\n```\n\nSINCE WE DELETED A COLUMN WE NEED TO START AGAIN BECAUSE ORDER OF CHARACTERS HAS CHANGED\n\n```\n[ 21, 3, 24 ], [ 21, 4, 8 ], [ 25, 21, 2 ], [ 25, 11, 3 ]\n     i-1             i\n  21==21 so we continue to next character\n  skip 3 and 4\n  24<8  We detected invalid order, column at index 2 needs to be deleted (marking it as deleted)\n```\n\nEventually result will be 2\n\n# Complexity\n- Time complexity:\n$$O(n^2*m)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```javascript []\nvar minDeletionSize = function(strs) {\n    const aCode=\'a\'.charCodeAt(0), m=strs[0].length, deleted=new Set();\n    // Convert to number array\n    strs=strs.map(s=>[...s].map(c=>c.charCodeAt(0)-aCode));\n\n    const needDeletion=(src,dst)=>{\n        let prev=undefined;\n        for(let i=0;i<m;i++){\n            if(deleted.has(i)) continue;  // skip deleted columns\n            if(src[i]>dst[i]) return i; // not in order returning a column for deletion\n            else if(src[i]===dst[i]) continue; // not clear yet which str is greater continue to a next char\n            break;\n        }\n        return undefined;\n    }\n    const compare=()=>{\n        for(let i=1;i<strs.length;i++){\n            const deletedColumn=needDeletion(strs[i-1], strs[i]);\n            if(deletedColumn!==undefined){\n                deleted.add(deletedColumn);\n                compare(); // since order changed, we need to run the whole thing again\n            }\n        }\n    }\n\n    compare();\n    return deleted.size;\n};\n```
['JavaScript']