package com.fishercoder.solutions;

/**
 * 944. Delete Columns to Make Sorted
 *
 * We are given an array A of N lowercase letter strings, all of the same length.
 * Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.
 * For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3},
 * then the final array after deletions is ["bef", "vyz"], and the remaining columns of A are ["b","v"], ["e","y"],
 * and ["f","z"].  (Formally, the c-th column is [A[0][c], A[1][c], ..., A[A.length-1][c]].)
 *
 * Suppose we chose a set of deletion indices D such that after deletions, each remaining column in A is in non-decreasing sorted order.
 *
 * Return the minimum possible value of D.length.
 *
 * Example 1:
 *
 * Input: ["cba","daf","ghi"]
 * Output: 1
 * Explanation:
 * After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order.
 * If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order.
 * Example 2:
 *
 * Input: ["a","b"]
 * Output: 0
 * Explanation: D = {}
 * Example 3:
 *
 * Input: ["zyx","wvu","tsr"]
 * Output: 3
 * Explanation: D = {0, 1, 2}
 *
 *
 * Note:
 *
 * 1 <= A.length <= 100
 * 1 <= A[i].length <= 1000
 * */
public class _944 {
  public static class Solution1 {
    public int minDeletionSize(String[] A) {
      if (A == null || A.length == 0) {
        return 0;
      }
      int deletion = 0;
      for (int i = 0; i < A[0].length(); i++) {
        for (int j = 0; j < A.length - 1; j++) {
          if (A[j].charAt(i) > A[j + 1].charAt(i)) {
            deletion++;
            break;
          }
        }
      }
      return deletion;
    }
  }
}

@@ -33,1269 +33,8 @@
 s;%0A%0A
-/**%0A * 944. Delete Columns to Make Sorted%0A *%0A * We are given an array A of N lowercase letter strings, all of the same length.%0A * Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.%0A * For example, if we have an array A = %5B%22abcdef%22,%22uvwxyz%22%5D and deletion indices %7B0, 2, 3%7D,%0A * then the final array after deletions is %5B%22bef%22, %22vyz%22%5D, and the remaining columns of A are %5B%22b%22,%22v%22%5D, %5B%22e%22,%22y%22%5D,%0A * and %5B%22f%22,%22z%22%5D.  (Formally, the c-th column is %5BA%5B0%5D%5Bc%5D, A%5B1%5D%5Bc%5D, ..., A%5BA.length-1%5D%5Bc%5D%5D.)%0A *%0A * Suppose we chose a set of deletion indices D such that after deletions, each remaining column in A is in non-decreasing sorted order.%0A *%0A * Return the minimum possible value of D.length.%0A *%0A * Example 1:%0A *%0A * Input: %5B%22cba%22,%22daf%22,%22ghi%22%5D%0A * Output: 1%0A * Explanation:%0A * After choosing D = %7B1%7D, each column %5B%22c%22,%22d%22,%22g%22%5D and %5B%22a%22,%22f%22,%22i%22%5D are in non-decreasing sorted order.%0A * If we chose D = %7B%7D, then a column %5B%22b%22,%22a%22,%22h%22%5D would not be in non-decreasing sorted order.%0A * Example 2:%0A *%0A * Input: %5B%22a%22,%22b%22%5D%0A * Output: 0%0A * Explanation: D = %7B%7D%0A * Example 3:%0A *%0A * Input: %5B%22zyx%22,%22wvu%22,%22tsr%22%5D%0A * Output: 3%0A * Explanation: D = %7B0, 1, 2%7D%0A *%0A *%0A * Note:%0A *%0A * 1 %3C= A.length %3C= 100%0A * 1 %3C= A%5Bi%5D.length %3C= 1000%0A * */%0A
 publ
@@ -49,16 +49,18 @@
  _944 %7B%0A
+  
   public
@@ -85,24 +85,28 @@
 tion1 %7B%0A    
+  
+  
 public int m
@@ -136,24 +136,30 @@
  A) %7B%0A      
+   
+   
 if (A == nul
@@ -176,24 +176,32 @@
 gth == 0) %7B%0A
+        
         retu
@@ -212,24 +212,36 @@
 ;%0A      
+ 
-%7D%0A
+     %7D%0A    
       
+  
 int dele
@@ -246,24 +246,30 @@
 letion = 0;%0A
+      
       for (i
@@ -304,32 +304,40 @@
  i++) %7B%0A        
+   
+     
 for (int j = 0; 
@@ -367,24 +367,34 @@
 %7B%0A          
+      
+    
 if (A%5Bj%5D.cha
@@ -420,24 +420,36 @@
 harAt(i)) %7B%0A
+            
             
@@ -472,16 +472,28 @@
         
+     
+       
 break;%0A 
@@ -505,34 +505,64 @@
     
+    
-%7D%0A        %7D%0A      %7D%0A
+      %7D%0A                %7D%0A            %7D%0A  
       
+    
 retu
@@ -578,16 +578,22 @@
 on;%0A    
-%7D%0A
+    %7D%0A  
   %7D%0A%7D%0A

refactor 944