comefrom: <awangdev>265. Paint House II_4.java
code: public int minCostII(int[][] costs) {
          if (costs == null || costs.length == 0) {
              return 0;
          } else if (costs.length == 1 && costs[0].length == 1) {
              return costs[0][0];
          }
          int minCost = Integer.MAX_VALUE;
          int n = costs.length, k = costs[0].length;
          int[][] dp = new int[2][k]; 
  
          for (int i = 1; i <= n; i++) {
              int minIndex = -1, minSecIndex = -1;
              for (int j = 0; j < k; j++) {
                  if (minIndex == -1 || dp[(i - 1) % 2][j] < dp[(i - 1) % 2][minIndex]) {
                      minSecIndex = minIndex;
                      minIndex = j;
                  } else if (minSecIndex == -1 || dp[(i - 1) % 2][j] < dp[(i - 1) % 2][minSecIndex]) {
                      minSecIndex = j;
                  }
              }
  
              for (int j = 0; j < k; j++) {
                  if (j == minIndex) dp[i % 2][j] = dp[(i - 1) % 2][minSecIndex] + costs[i - 1][j];
                  else dp[i % 2][j] = dp[(i - 1) % 2][minIndex] + costs[i - 1][j];
                  
                  if (i == n) minCost = Math.min(minCost, dp[i % 2][j]);   
              }
          }
          return minCost;
       }
masked: public int sample_funcname ( int [ ] [ ] var_0 ) {
    if ( var_0 == null || var_0 . length == 0 ) {
      return 0 ;
    }
    else if ( var_0 . length == 1 && var_0 [ 0 ] . length == 1 ) {
      return var_0 [ 0 ] [ 0 ] ;
    }
    int var_7 = Integer . MAX_VALUE ;
    int var_8 = var_0 . length , var_9 = var_0 [ 0 ] . length ;
    int [ ] [ ] var_11 = new int [ 2 ] [ var_9 ] ;
    for ( int var_12 = 1 ;
    var_12 <= var_8 ;
    var_12 ++ ) {
      int var_13 = - 1 , var_14 = - 1 ;
      for ( int var_15 = 0 ;
      var_15 < var_9 ;
      var_15 ++ ) {
        if ( var_13 == - 1 || var_11 [ ( var_12 - 1 ) % 2 ] [ var_15 ] < var_11 [ ( var_12 - 1 ) % 2 ] [ var_13 ] ) {
          var_14 = var_13 ;
          var_13 = var_15 ;
        }
        else if ( var_14 == - 1 || var_11 [ ( var_12 - 1 ) % 2 ] [ var_15 ] < var_11 [ ( var_12 - 1 ) % 2 ] [ var_14 ] ) {
          var_14 = var_15 ;
        }
      }
      for ( int var_15 = 0 ;
      var_15 < var_9 ;
      var_15 ++ ) {
        if ( var_15 == var_13 ) var_11 [ var_12 % 2 ] [ var_15 ] = var_11 [ ( var_12 - 1 ) % 2 ] [ var_14 ] + var_0 [ var_12 - 1 ] [ var_15 ] ;
        else var_11 [ var_12 % 2 ] [ var_15 ] = var_11 [ ( var_12 - 1 ) % 2 ] [ var_13 ] + var_0 [ var_12 - 1 ] [ var_15 ] ;
        if ( var_12 == var_8 ) var_7 = Math . min ( var_7 , var_11 [ var_12 % 2 ] [ var_15 ] ) ;
      }
    }
    return var_7 ;
  }
  