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_1 = Integer . MAX_VALUE ;
    int var_2 = var_0 . length , var_3 = var_0 [ 0 ] . length ;
    int [ ] [ ] var_4 = new int [ 2 ] [ var_3 ] ;
    for ( int var_5 = 1 ;
    var_5 <= var_2 ;
    var_5 ++ ) {
      int var_6 = - 1 , var_7 = - 1 ;
      for ( int var_8 = 0 ;
      var_8 < var_3 ;
      var_8 ++ ) {
        if ( var_6 == - 1 || var_4 [ ( var_5 - 1 ) % 2 ] [ var_8 ] < var_4 [ ( var_5 - 1 ) % 2 ] [ var_6 ] ) {
          var_7 = var_6 ;
          var_6 = var_8 ;
        }
        else if ( var_7 == - 1 || var_4 [ ( var_5 - 1 ) % 2 ] [ var_8 ] < var_4 [ ( var_5 - 1 ) % 2 ] [ var_7 ] ) {
          var_7 = var_8 ;
        }
      }
      for ( int var_8 = 0 ;
      var_8 < var_3 ;
      var_8 ++ ) {
        if ( var_8 == var_6 ) var_4 [ var_5 % 2 ] [ var_8 ] = var_4 [ ( var_5 - 1 ) % 2 ] [ var_7 ] + var_0 [ var_5 - 1 ] [ var_8 ] ;
        else var_4 [ var_5 % 2 ] [ var_8 ] = var_4 [ ( var_5 - 1 ) % 2 ] [ var_6 ] + var_0 [ var_5 - 1 ] [ var_8 ] ;
        if ( var_5 == var_2 ) var_1 = Math . min ( var_1 , var_4 [ var_5 % 2 ] [ var_8 ] ) ;
      }
    }
    return var_1 ;
  }
  