Delete Columns to Make Sorted II
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the 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 * @param {string[]} strs\n * @return {number}\n */\nfunction minDeletionSize(strs) {\n  const n = strs[0].length;\n  let ans = 0;\n  const sorted = new Array(strs.length - 1).fill(false);\n\n  for (let j = 0; j < n; ++j) {\n    let i;\n    for (i = 0; i + 1 < strs.length; ++i) {\n      if (!sorted[i] && strs[i].charAt(j) > strs[i + 1].charAt(j)) {\n        ++ans;\n        break;\n      }\n    }\n    // Already compared each pair, update the sorted array if needed\n    if (i + 1 === strs.length) {\n      for (i = 0; i + 1 < strs.length; ++i) {\n        sorted[i] = sorted[i] || strs[i].charAt(j) < strs[i + 1].charAt(j);\n      }\n    }\n  }\n\n  return ans;\n}\n```
['JavaScript']