<awangdev>361. Bomb Enemy_2.java
public int maxKilledEnemies(char[][] grid) {
        if (grid == null || grid.length == 0 || grid[0].length == 0) return 0;
        int m = grid.length, n = grid[0].length;
        int[] colSum = new int[n];
        int max = 0;
        int row = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {                
                if (j == 0 || grid[i][j - 1] == 'W') {
                    row = 0;
                    for (int k = j; k < n && grid[i][k] != 'W'; k++) {
                        row += grid[i][k] == 'E' ? 1 : 0;
                    }
                }
                
                if (i == 0 || grid[i - 1][j] == 'W') {
                    colSum[j] = 0;
                    for (int k = i; k < m && grid[k][j] != 'W'; k++) {
                        colSum[j] += grid[k][j] == 'E' ? 1 : 0;
                    }
                }
                if (grid[i][j] == '0') max = Math.max(max, colSum[j] + row);
            }
        }
        return max;
    }
public int sample_funcname ( char [ ] [ ] var_0 ) {
  if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] . length == 0 ) return 0 ;
  int var_4 = var_0 . length , var_5 = var_0 [ 0 ] . length ;
  int [ ] var_6 = new int [ var_5 ] ;
  int max = 0 ;
  int var_8 = 0 ;
  for ( int var_9 = 0 ;
  var_9 < var_4 ;
  var_9 ++ ) {
    for ( int var_10 = 0 ;
    var_10 < var_5 ;
    var_10 ++ ) {
      if ( var_10 == 0 || var_0 [ var_9 ] [ var_10 - 1 ] == 'W' ) {
        var_8 = 0 ;
        for ( int var_13 = var_10 ;
        var_13 < var_5 && var_0 [ var_9 ] [ var_13 ] != 'W' ;
        var_13 ++ ) {
          var_8 += var_0 [ var_9 ] [ var_13 ] == 'E' ? 1 : 0 ;
        }
      }
      if ( var_9 == 0 || var_0 [ var_9 - 1 ] [ var_10 ] == 'W' ) {
        var_6 [ var_10 ] = 0 ;
        for ( int var_13 = var_9 ;
        var_13 < var_4 && var_0 [ var_13 ] [ var_10 ] != 'W' ;
        var_13 ++ ) {
          var_6 [ var_10 ] += var_0 [ var_13 ] [ var_10 ] == 'E' ? 1 : 0 ;
        }
      }
      if ( var_0 [ var_9 ] [ var_10 ] == '0' ) max = Math . max ( max , var_6 [ var_10 ] + var_8 ) ;
    }
  }
  return max ;
}
